Skip to content

Commit

Permalink
fix: no autocompletion when in block name
Browse files Browse the repository at this point in the history
  • Loading branch information
dummdidumm committed Dec 12, 2024
1 parent cdd3f2e commit 6e77f92
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,21 @@ export class CompletionsProviderImpl implements CompletionsProvider<CompletionRe
return null;
}

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

if (
!inScript &&
wordInfo.word[0] === '{' &&
(wordInfo.word[1] === '#' ||
wordInfo.word[1] === '@' ||
wordInfo.word[1] === ':' ||
wordInfo.word[1] === '/')
) {
// Typing something like {/if}
return null;
}

const componentInfo = getComponentAtPosition(lang, document, tsDoc, position);
const attributeContext = componentInfo && getAttributeContextAtPosition(document, position);
const eventAndSlotLetCompletions = this.getEventAndSlotLetCompletions(
Expand Down Expand Up @@ -289,7 +302,7 @@ export class CompletionsProviderImpl implements CompletionsProvider<CompletionRe
const isCompletionInTag = svelteIsInTag(svelteNode, originalOffset);
const isHandlerCompletion =
svelteNode?.type === 'EventHandler' && svelteNode.parent?.type === 'Element';
const preferComponents = wordInfo.word[0] === '<' || isInScript(position, tsDoc);
const preferComponents = wordInfo.word[0] === '<' || inScript;

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

0 comments on commit 6e77f92

Please sign in to comment.