Skip to content

Commit 6e77f92

Browse files
committed
fix: no autocompletion when in block name
1 parent cdd3f2e commit 6e77f92

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

packages/language-server/src/plugins/typescript/features/CompletionProvider.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,21 @@ export class CompletionsProviderImpl implements CompletionsProvider<CompletionRe
189189
return null;
190190
}
191191

192+
const inScript = isInScript(position, tsDoc);
192193
const wordInfo = this.getWordAtPosition(document, originalOffset);
193194

195+
if (
196+
!inScript &&
197+
wordInfo.word[0] === '{' &&
198+
(wordInfo.word[1] === '#' ||
199+
wordInfo.word[1] === '@' ||
200+
wordInfo.word[1] === ':' ||
201+
wordInfo.word[1] === '/')
202+
) {
203+
// Typing something like {/if}
204+
return null;
205+
}
206+
194207
const componentInfo = getComponentAtPosition(lang, document, tsDoc, position);
195208
const attributeContext = componentInfo && getAttributeContextAtPosition(document, position);
196209
const eventAndSlotLetCompletions = this.getEventAndSlotLetCompletions(
@@ -289,7 +302,7 @@ export class CompletionsProviderImpl implements CompletionsProvider<CompletionRe
289302
const isCompletionInTag = svelteIsInTag(svelteNode, originalOffset);
290303
const isHandlerCompletion =
291304
svelteNode?.type === 'EventHandler' && svelteNode.parent?.type === 'Element';
292-
const preferComponents = wordInfo.word[0] === '<' || isInScript(position, tsDoc);
305+
const preferComponents = wordInfo.word[0] === '<' || inScript;
293306

294307
const completionItems: CompletionItem[] = customCompletions;
295308
const isValidCompletion = createIsValidCompletion(document, position, !!tsDoc.parserError);

0 commit comments

Comments
 (0)