diff --git a/src/debounceCompletions.ts b/src/debounceCompletions.ts index 88246e1f2c..311a533049 100644 --- a/src/debounceCompletions.ts +++ b/src/debounceCompletions.ts @@ -14,7 +14,7 @@ export default async function debounceCompletions( vscode.InlineCompletionList | undefined > { const { time, value: current } = await timed(() => - getInlineCompletionItems(document, position) + getInlineCompletionItems(document, position, token) ); const debounceTime = calculateDebounceMs(time); @@ -30,7 +30,7 @@ export default async function debounceCompletions( } // re fetch the most updated suggestions - return getInlineCompletionItems(document, position); + return getInlineCompletionItems(document, position, token); } async function debounceOrCancelOnRequest( diff --git a/src/getInlineCompletionItems.ts b/src/getInlineCompletionItems.ts index b93c4143f4..5a55730806 100644 --- a/src/getInlineCompletionItems.ts +++ b/src/getInlineCompletionItems.ts @@ -8,11 +8,15 @@ import { isMultiline } from "./utils/utils"; export default async function getInlineCompletionItems( document: vscode.TextDocument, - position: vscode.Position + position: vscode.Position, + cancellationToken: vscode.CancellationToken ): Promise> { const response = await runCompletion({ document, position, + retry: { + cancellationToken, + }, }); const completions = response?.results.map( diff --git a/src/test/suite/completion.test.ts b/src/test/suite/completion.test.ts index 7365170fcf..89d98cf402 100644 --- a/src/test/suite/completion.test.ts +++ b/src/test/suite/completion.test.ts @@ -197,7 +197,7 @@ describe("Should do completion", () => { verify( stdinMock.write(new SimpleAutocompleteRequestMatcher(), "utf8") - ).once(); + ).atLeast(1); }); it("should skip completion request on text deletion", async () => { await openADocWith("test deletion"); @@ -246,7 +246,7 @@ describe("Should do completion", () => { verify( stdinMock.write(new SimpleAutocompleteRequestMatcher(), "utf8") - ).once(); + ).atLeast(1); }); it("should do completion on new line in python", async () => { await openADocWith("def binary_search(arr, target):", "python"); @@ -256,7 +256,7 @@ describe("Should do completion", () => { verify( stdinMock.write(new SimpleAutocompleteRequestMatcher(), "utf8") - ).once(); + ).atLeast(1); }); it("should not change the replace range end in case of multiline suffix", async () => { const editor = await openADocWith("consol"); @@ -329,7 +329,7 @@ describe("Should do completion", () => { verify( stdinMock.write(new SimpleAutocompleteRequestMatcher(), "utf8") - ).once(); + ).atLeast(1); }); }); it("should should query tabnine if the change is auto closed brackets", async () => { @@ -478,7 +478,7 @@ describe("Should do completion", () => { new SimpleAutocompleteRequestMatcher(SECOND_PREFIX), "utf8" ) - ).twice(); + ).atLeast(2); }); it("should report suggestion about to shown after debounce", async () => { mockGetDebounceConfig(SHORT_DEBOUNCE_VALUE);