diff --git a/core/autocomplete/CompletionProvider.ts b/core/autocomplete/CompletionProvider.ts index 24815f501..9667352fd 100644 --- a/core/autocomplete/CompletionProvider.ts +++ b/core/autocomplete/CompletionProvider.ts @@ -261,13 +261,10 @@ export class CompletionProvider { ////////// - // Do some stuff later so as not to block return. Latency matters - const completionToCache = outcome.completion; - setTimeout(async () => { - if (!outcome.cacheHit) { - (await this.autocompleteCache).put(outcome.prefix, completionToCache); - } - }, 100); + // Save to cache + if (!outcome.cacheHit) { + (await this.autocompleteCache).put(outcome.prefix, outcome.completion); + } // When using the JetBrains extension, Mark as displayed const ideType = (await this.ide.getIdeInfo()).ideType; diff --git a/core/autocomplete/filtering/test/filter.test.ts b/core/autocomplete/filtering/test/filter.test.ts index b2e025a4b..e6c07b951 100644 --- a/core/autocomplete/filtering/test/filter.test.ts +++ b/core/autocomplete/filtering/test/filter.test.ts @@ -14,7 +14,7 @@ const filterTestCases = (tests: AutocompleteFileringTestInput[]) => { return tests; }; -describe("llms/Mock", () => { +describe("Autocomplete filtering tests", () => { beforeAll(async () => { tearDownTestDir(); setUpTestDir(); @@ -24,27 +24,25 @@ describe("llms/Mock", () => { tearDownTestDir(); }); - describe("Autocomplete Filtering Tests", () => { - beforeEach(async () => { - await new Promise((resolve) => setTimeout(resolve, 50)); - }); + beforeEach(async () => { + await new Promise((resolve) => setTimeout(resolve, 50)); + }); - describe("Should return unmodified LLM output", () => { - it.each(filterTestCases(TEST_CASES_WITHOUT_DIFF))( - "$description", - async (testCase) => { - await testAutocompleteFiltering(testCase); - }, - ); - }); + describe("Should return unmodified LLM output", () => { + it.each(filterTestCases(TEST_CASES_WITHOUT_DIFF))( + "$description", + async (testCase) => { + await testAutocompleteFiltering(testCase); + }, + ); + }); - describe("Should return modified LLM output", () => { - it.each(filterTestCases(TEST_CASES_WITH_DIFF))( - "$description", - async (testCase) => { - await testAutocompleteFiltering(testCase); - }, - ); - }); + describe("Should return modified LLM output", () => { + it.each(filterTestCases(TEST_CASES_WITH_DIFF))( + "$description", + async (testCase) => { + await testAutocompleteFiltering(testCase); + }, + ); }); });