Merge pull request #6028 from ShamanicArts/forceAutocomplete
feat: Add shortcut to force autocomplete (VSCode)
This commit is contained in:
commit
00911c6055
10 changed files with 67 additions and 7 deletions
5
binary/package-lock.json
generated
5
binary/package-lock.json
generated
|
|
@ -52,7 +52,7 @@
|
|||
"@aws-sdk/credential-providers": "^3.778.0",
|
||||
"@continuedev/config-types": "^1.0.13",
|
||||
"@continuedev/config-yaml": "file:../packages/config-yaml",
|
||||
"@continuedev/fetch": "^1.0.10",
|
||||
"@continuedev/fetch": "^1.0.13",
|
||||
"@continuedev/llm-info": "^1.0.8",
|
||||
"@continuedev/openai-adapters": "^1.0.25",
|
||||
"@modelcontextprotocol/sdk": "^1.12.0",
|
||||
|
|
@ -144,7 +144,8 @@
|
|||
"onnxruntime-common": "1.14.0",
|
||||
"onnxruntime-web": "1.14.0",
|
||||
"ts-jest": "^29.1.1",
|
||||
"typescript": "^5.6.3"
|
||||
"typescript": "^5.6.3",
|
||||
"vitest": "^3.1.4"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20.19.0"
|
||||
|
|
|
|||
|
|
@ -127,6 +127,7 @@ export class CompletionProvider {
|
|||
public async provideInlineCompletionItems(
|
||||
input: AutocompleteInput,
|
||||
token: AbortSignal | undefined,
|
||||
force?: boolean,
|
||||
): Promise<AutocompleteOutcome | undefined> {
|
||||
try {
|
||||
// Create abort signal if not given
|
||||
|
|
@ -146,8 +147,12 @@ export class CompletionProvider {
|
|||
const options = await this._getAutocompleteOptions(llm);
|
||||
|
||||
// Debounce
|
||||
if (await this.debouncer.delayAndShouldDebounce(options.debounceDelay)) {
|
||||
return undefined;
|
||||
if (!force) {
|
||||
if (
|
||||
await this.debouncer.delayAndShouldDebounce(options.debounceDelay)
|
||||
) {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
if (llm.promptTemplates?.autocomplete) {
|
||||
|
|
|
|||
4
core/package-lock.json
generated
4
core/package-lock.json
generated
|
|
@ -113,10 +113,10 @@
|
|||
"node": ">=20.19.0"
|
||||
}
|
||||
},
|
||||
"../../../../dallin/documents/code/continuedev/continue/packages/config-yaml": {
|
||||
"../../../dallin/documents/code/continuedev/continue/packages/config-yaml": {
|
||||
"extraneous": true
|
||||
},
|
||||
"../../../../documents/code/continuedev/continue/packages/config-yaml": {
|
||||
"../../../documents/code/continuedev/continue/packages/config-yaml": {
|
||||
"version": "1.0.78",
|
||||
"extraneous": true,
|
||||
"license": "Apache-2.0",
|
||||
|
|
|
|||
|
|
@ -23,3 +23,7 @@ Reject a full suggestion with <kbd>Esc</kbd>
|
|||
### Partially accepting a suggestion
|
||||
|
||||
For more granular control, use <kbd>cmd/ctrl</kbd> + <kbd>→</kbd> to accept parts of the suggestion word-by-word.
|
||||
|
||||
### Forcing a suggestion (VS Code)
|
||||
|
||||
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>**.
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { expect } from "chai";
|
||||
import { TextEditor } from "vscode-extension-tester";
|
||||
import { TextEditor, VSBrowser, Workbench } from "vscode-extension-tester";
|
||||
|
||||
import { DEFAULT_TIMEOUT } from "../constants";
|
||||
import { AutocompleteSelectors } from "../selectors/Autocomplete.selectors";
|
||||
|
|
@ -29,4 +29,17 @@ export class AutocompleteActions {
|
|||
);
|
||||
expect(ghostText1).to.equal(messagePair1.llmResponse);
|
||||
}
|
||||
|
||||
public static async forceCompletion(editor: TextEditor): Promise<string> {
|
||||
await editor.setText("def main():\n ");
|
||||
await editor.moveCursor(2, 5);
|
||||
|
||||
await new Workbench().executeCommand("Continue: Force Autocomplete");
|
||||
|
||||
const ghostText = await TestUtils.waitForSuccess(() =>
|
||||
AutocompleteSelectors.getGhostTextContent(VSBrowser.instance.driver)
|
||||
);
|
||||
|
||||
return ghostText;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import { expect } from "chai";
|
||||
import { EditorView, TextEditor } from "vscode-extension-tester";
|
||||
|
||||
import { AutocompleteActions } from "../actions/Autocomplete.actions";
|
||||
|
|
@ -23,4 +24,8 @@ describe("Autocomplete", () => {
|
|||
it("Should display completions", async () => {
|
||||
await AutocompleteActions.testCompletions(editor);
|
||||
}).timeout(DEFAULT_TIMEOUT.XL);
|
||||
it("Should force a completion using the command", async () => {
|
||||
const ghostText = await AutocompleteActions.forceCompletion(editor);
|
||||
expect(ghostText).to.not.be.empty;
|
||||
}).timeout(DEFAULT_TIMEOUT.XL);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -225,6 +225,11 @@
|
|||
"title": "Toggle Autocomplete Enabled",
|
||||
"group": "Continue"
|
||||
},
|
||||
{
|
||||
"command": "continue.forceAutocomplete",
|
||||
"title": "Continue: Force Autocomplete",
|
||||
"category": "Continue"
|
||||
},
|
||||
{
|
||||
"command": "continue.selectFilesAsContext",
|
||||
"category": "Continue",
|
||||
|
|
@ -411,6 +416,12 @@
|
|||
"key": "ctrl+k ctrl+a",
|
||||
"when": "!terminalFocus"
|
||||
},
|
||||
{
|
||||
"command": "continue.forceAutocomplete",
|
||||
"key": "ctrl+alt+space",
|
||||
"mac": "cmd+alt+space",
|
||||
"when": "editorTextFocus && !editorHasSelection && !editorReadOnly && !inSnippetMode"
|
||||
},
|
||||
{
|
||||
"command": "continue.applyCodeFromChat",
|
||||
"mac": "alt+a",
|
||||
|
|
|
|||
|
|
@ -189,6 +189,10 @@ export class ContinueCompletionProvider
|
|||
// Handle commit message input box
|
||||
let manuallyPassPrefix: string | undefined = undefined;
|
||||
|
||||
// handle manual autocompletion trigger
|
||||
const wasManuallyTriggered =
|
||||
context.triggerKind === vscode.InlineCompletionTriggerKind.Invoke;
|
||||
|
||||
const input: AutocompleteInput = {
|
||||
pos,
|
||||
manuallyPassFileContents,
|
||||
|
|
@ -208,6 +212,7 @@ export class ContinueCompletionProvider
|
|||
await this.completionProvider.provideInlineCompletionItems(
|
||||
input,
|
||||
signal,
|
||||
wasManuallyTriggered,
|
||||
);
|
||||
|
||||
if (!outcome || !outcome.completion) {
|
||||
|
|
|
|||
|
|
@ -624,6 +624,18 @@ const getCommandsMap: (
|
|||
}
|
||||
}
|
||||
},
|
||||
"continue.forceAutocomplete": async () => {
|
||||
captureCommandTelemetry("forceAutocomplete");
|
||||
|
||||
// 1. Explicitly hide any existing suggestion. This clears VS Code's cache for the current position.
|
||||
await vscode.commands.executeCommand("editor.action.inlineSuggest.hide");
|
||||
|
||||
// 2. Now trigger a new one. VS Code has no cached suggestion, so it's forced to call our provider.
|
||||
await vscode.commands.executeCommand(
|
||||
"editor.action.inlineSuggest.trigger",
|
||||
);
|
||||
},
|
||||
|
||||
"continue.openTabAutocompleteConfigMenu": async () => {
|
||||
captureCommandTelemetry("openTabAutocompleteConfigMenu");
|
||||
|
||||
|
|
|
|||
|
|
@ -75,6 +75,10 @@ const vscodeShortcuts: Omit<KeyboardShortcutProps, "isEven">[] = [
|
|||
shortcut: "cmd K cmd A",
|
||||
description: "Toggle Autocomplete Enabled",
|
||||
},
|
||||
{
|
||||
shortcut: "cmd alt space",
|
||||
description: "Force an Autocomplete Trigger",
|
||||
},
|
||||
{
|
||||
shortcut: "cmd K cmd M",
|
||||
description: "Toggle Full Screen",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue