Extension: request the next edit right after accepting a suggestion (0.6.4)
ci / build (push) Canceled after 0s

Accepting a completion or a next-edit cancels the debounce timer and asks the daemon for
the follow-up immediately; next-edits chain. Setting localAutocomplete.nextEdit.afterAccept.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01J39imRDT8L7xYbWzsVWd8A
This commit is contained in:
2026-10-04 01:11:39 +00:00
co-authored by Claude Opus 5.5
parent 3dc916834f
commit 9ccf108835
3 changed files with 23 additions and 1 deletions
+11
View File
@@ -259,6 +259,7 @@ const modelSupportsNextEdit = () => !!(daemonConfig && daemonConfig.models[daemo
// ---------- next-edit prediction (models trained for it, e.g. Stage E)
const nextEdit = new NextEditController(s => {
api('POST', '/v1/feedback', { event: 'next-edit-accepted', lines: s.newText.split('\n').length }).catch(() => {})
nextEditAfterAccept('accepted-next-edit')
})
let nextEditTimer: NodeJS.Timeout | null = null
let nextEditAbort: AbortController | null = null
@@ -281,6 +282,15 @@ async function requestNextEdit(editor: vscode.TextEditor, reason: string) {
}
}
/** Accepting a suggestion (next-edit or completion) asks for the follow-up right away instead of after the typing pause. */
function nextEditAfterAccept(reason: string) {
const editor = vscode.window.activeTextEditor
if (!editor || !modelSupportsNextEdit() || !settings().get<boolean>('nextEdit.afterAccept', true)) return
if (nextEditTimer) clearTimeout(nextEditTimer)
// Next tick: the accepted text and the cursor move have been applied by then.
nextEditTimer = setTimeout(() => void requestNextEdit(editor, reason), 0)
}
function scheduleNextEdit(editor: vscode.TextEditor, reason: string, delay: number) {
if (nextEditTimer) clearTimeout(nextEditTimer)
nextEditTimer = setTimeout(() => void requestNextEdit(editor, reason), delay)
@@ -535,6 +545,7 @@ export async function activate(ctx: vscode.ExtensionContext) {
vscode.commands.registerCommand('localAutocomplete.showLog', () => log.show()),
vscode.commands.registerCommand('localAutocomplete.accepted', (requestId: string, text: string) => {
api('POST', '/v1/feedback', { requestId, event: 'accepted', chars: text.length }).catch(() => {})
nextEditAfterAccept('accepted-completion')
}),
vscode.workspace.onDidChangeConfiguration(e => {
if (!e.affectsConfiguration('localAutocomplete')) return