Elffuss BraidHub

kikocis/continue public

Merge pull request #6028 from ShamanicArts/forceAutocomplete

feat: Add shortcut to force autocomplete (VSCode)
Changesetd691089ac9f799b121efc2dab12e8198b25ef8df5ea2df2d184d4e1aa63d313e
AuthorPatrick Erichsen <patrick.a.erichsen@gmail.com> · 2025-06-12 17:12 -07:00
CommitterGitHub <noreply@github.com> · 2025-06-12 17:12 -07:00
Parents5fc2af2ce6c9, ff6e3c1dcf5b

Browse the files at this changeset

10 files changed

modified binary/package-lock.json +3 −2
@@ -52,7 +52,7 @@
5252 "@aws-sdk/credential-providers": "^3.778.0",
5353 "@continuedev/config-types": "^1.0.13",
5454 "@continuedev/config-yaml": "file:../packages/config-yaml",
55- "@continuedev/fetch": "^1.0.10",
55+ "@continuedev/fetch": "^1.0.13",
5656 "@continuedev/llm-info": "^1.0.8",
5757 "@continuedev/openai-adapters": "^1.0.25",
5858 "@modelcontextprotocol/sdk": "^1.12.0",
@@ -144,7 +144,8 @@
144144 "onnxruntime-common": "1.14.0",
145145 "onnxruntime-web": "1.14.0",
146146 "ts-jest": "^29.1.1",
147- "typescript": "^5.6.3"
147+ "typescript": "^5.6.3",
148+ "vitest": "^3.1.4"
148149 },
149150 "engines": {
150151 "node": ">=20.19.0"
modified core/autocomplete/CompletionProvider.ts +7 −2
@@ -127,6 +127,7 @@
127127 public async provideInlineCompletionItems(
128128 input: AutocompleteInput,
129129 token: AbortSignal | undefined,
130+ force?: boolean,
130131 ): Promise<AutocompleteOutcome | undefined> {
131132 try {
132133 // Create abort signal if not given
@@ -146,8 +147,12 @@
146147 const options = await this._getAutocompleteOptions(llm);
147148
148149 // Debounce
149- if (await this.debouncer.delayAndShouldDebounce(options.debounceDelay)) {
150- return undefined;
150+ if (!force) {
151+ if (
152+ await this.debouncer.delayAndShouldDebounce(options.debounceDelay)
153+ ) {
154+ return undefined;
155+ }
151156 }
152157
153158 if (llm.promptTemplates?.autocomplete) {
modified core/package-lock.json +0 −0

Not shown: the file is larger than the hub shows, or this page holds as much as it shows. View the file.

modified docs/docs/autocomplete/how-to-use-it.md +4 −0
@@ -23,3 +23,7 @@
2323 ### Partially accepting a suggestion
2424
2525 For more granular control, use <kbd>cmd/ctrl</kbd> + <kbd>→</kbd> to accept parts of the suggestion word-by-word.
26+
27+### Forcing a suggestion (VS Code)
28+
29+If you want to trigger a suggestion immediately without waiting, or if you've dismissed a suggestion and want a new one, you can force it by using the keyboard shortcut **<kbd>cmd/ctrl</kbd> + <kbd>alt</kbd> + <kbd>space</kbd>**.
modified extensions/vscode/e2e/actions/Autocomplete.actions.ts +14 −1
@@ -1,5 +1,5 @@
11 import { expect } from "chai";
2-import { TextEditor } from "vscode-extension-tester";
2+import { TextEditor, VSBrowser, Workbench } from "vscode-extension-tester";
33
44 import { DEFAULT_TIMEOUT } from "../constants";
55 import { AutocompleteSelectors } from "../selectors/Autocomplete.selectors";
@@ -29,4 +29,17 @@
2929 );
3030 expect(ghostText1).to.equal(messagePair1.llmResponse);
3131 }
32+
33+ public static async forceCompletion(editor: TextEditor): Promise<string> {
34+ await editor.setText("def main():\n ");
35+ await editor.moveCursor(2, 5);
36+
37+ await new Workbench().executeCommand("Continue: Force Autocomplete");
38+
39+ const ghostText = await TestUtils.waitForSuccess(() =>
40+ AutocompleteSelectors.getGhostTextContent(VSBrowser.instance.driver)
41+ );
42+
43+ return ghostText;
44+ }
3245 }
modified extensions/vscode/e2e/tests/Autocomplete.test.ts +5 −0
@@ -1,3 +1,4 @@
1+import { expect } from "chai";
12 import { EditorView, TextEditor } from "vscode-extension-tester";
23
34 import { AutocompleteActions } from "../actions/Autocomplete.actions";
@@ -23,4 +24,8 @@
2324 it("Should display completions", async () => {
2425 await AutocompleteActions.testCompletions(editor);
2526 }).timeout(DEFAULT_TIMEOUT.XL);
27+ it("Should force a completion using the command", async () => {
28+ const ghostText = await AutocompleteActions.forceCompletion(editor);
29+ expect(ghostText).to.not.be.empty;
30+ }).timeout(DEFAULT_TIMEOUT.XL);
2631 });
modified extensions/vscode/package.json +11 −0
@@ -225,6 +225,11 @@
225225 "title": "Toggle Autocomplete Enabled",
226226 "group": "Continue"
227227 },
228+ {
229+ "command": "continue.forceAutocomplete",
230+ "title": "Continue: Force Autocomplete",
231+ "category": "Continue"
232+ },
228233 {
229234 "command": "continue.selectFilesAsContext",
230235 "category": "Continue",
@@ -411,6 +416,12 @@
411416 "key": "ctrl+k ctrl+a",
412417 "when": "!terminalFocus"
413418 },
419+ {
420+ "command": "continue.forceAutocomplete",
421+ "key": "ctrl+alt+space",
422+ "mac": "cmd+alt+space",
423+ "when": "editorTextFocus && !editorHasSelection && !editorReadOnly && !inSnippetMode"
424+ },
414425 {
415426 "command": "continue.applyCodeFromChat",
416427 "mac": "alt+a",
modified extensions/vscode/src/autocomplete/completionProvider.ts +5 −0
@@ -189,6 +189,10 @@
189189 // Handle commit message input box
190190 let manuallyPassPrefix: string | undefined = undefined;
191191
192+ // handle manual autocompletion trigger
193+ const wasManuallyTriggered =
194+ context.triggerKind === vscode.InlineCompletionTriggerKind.Invoke;
195+
192196 const input: AutocompleteInput = {
193197 pos,
194198 manuallyPassFileContents,
@@ -208,6 +212,7 @@
208212 await this.completionProvider.provideInlineCompletionItems(
209213 input,
210214 signal,
215+ wasManuallyTriggered,
211216 );
212217
213218 if (!outcome || !outcome.completion) {
modified extensions/vscode/src/commands.ts +12 −0
@@ -624,6 +624,18 @@
624624 }
625625 }
626626 },
627+ "continue.forceAutocomplete": async () => {
628+ captureCommandTelemetry("forceAutocomplete");
629+
630+ // 1. Explicitly hide any existing suggestion. This clears VS Code's cache for the current position.
631+ await vscode.commands.executeCommand("editor.action.inlineSuggest.hide");
632+
633+ // 2. Now trigger a new one. VS Code has no cached suggestion, so it's forced to call our provider.
634+ await vscode.commands.executeCommand(
635+ "editor.action.inlineSuggest.trigger",
636+ );
637+ },
638+
627639 "continue.openTabAutocompleteConfigMenu": async () => {
628640 captureCommandTelemetry("openTabAutocompleteConfigMenu");
629641
modified gui/src/pages/config/KeyboardShortcuts.tsx +4 −0
@@ -75,6 +75,10 @@
7575 shortcut: "cmd K cmd A",
7676 description: "Toggle Autocomplete Enabled",
7777 },
78+ {
79+ shortcut: "cmd alt space",
80+ description: "Force an Autocomplete Trigger",
81+ },
7882 {
7983 shortcut: "cmd K cmd M",
8084 description: "Toggle Full Screen",