From e69f370be4550c03f56953f5359e4c204fe953fd Mon Sep 17 00:00:00 2001 From: Simon Holthausen Date: Tue, 5 Nov 2024 15:43:32 +0100 Subject: [PATCH] fix: prevent false-positive auto completions on Svelte components Because Svelte components take precedence, we leave out commit characters to not auto complete in weird places (e.g. when you have `foo.filter(a => a)`) and get autocomplete for component A, then a commit character of `.` would auto import the component which is not what we want Found after merging #2545 and playing around with it a bit --- .../typescript/features/CompletionProvider.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/packages/language-server/src/plugins/typescript/features/CompletionProvider.ts b/packages/language-server/src/plugins/typescript/features/CompletionProvider.ts index f620db97e..dae13c72c 100644 --- a/packages/language-server/src/plugins/typescript/features/CompletionProvider.ts +++ b/packages/language-server/src/plugins/typescript/features/CompletionProvider.ts @@ -695,7 +695,7 @@ export class CompletionsProviderImpl implements CompletionsProvider a)) and get autocomplete for component A, + // then a commit character of `.` would auto import the component which is not what we want + if (isSvelteComp) { + return ['>']; + } + // https://github.com/microsoft/vscode/blob/d012408e88ffabd6456c367df4d343654da2eb10/extensions/typescript-language-features/src/languageFeatures/completions.ts#L504 if (!options.checkCommitCharacters) { return undefined;