Skip to content

Commit

Permalink
fix svelte 4 again
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonlyu123 committed Jan 8, 2025
1 parent 4cedfaa commit f7a1cba
Showing 1 changed file with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ export class DocumentHighlightProviderImpl implements DocumentHighlightProvider

private findCandidateSvelteTag(tsDoc: SvelteDocumentSnapshot, offset: number) {
let candidate: TemplateNode | undefined;
const subBlocks = ['ThenBlock', 'CatchBlock', 'PendingBlock', 'ElseBlock'];

tsDoc.walkSvelteAst({
enter(node, parent, key) {
Expand All @@ -128,7 +129,21 @@ export class DocumentHighlightProviderImpl implements DocumentHighlightProvider
return;
}

if (node.type.endsWith('Block') || node.type.endsWith('Tag')) {
if (node.type.endsWith('Tag')) {
candidate = templateNode;
return;
}

// don't use sub-blocks so we can highlight the whole block
if (node.type.endsWith('Block') && !subBlocks.includes(node.type)) {
if (
// else if
node.type === 'IfBlock' &&
parent.type === 'ElseBlock' &&
parent.start === node.start
) {
return;
}
candidate = templateNode;
return;
}
Expand Down

0 comments on commit f7a1cba

Please sign in to comment.