Skip to content

Commit

Permalink
(fix) handle const in html pre-scanner (#1524)
Browse files Browse the repository at this point in the history
  • Loading branch information
dummdidumm committed Jun 15, 2022
1 parent 817843d commit 83d92c5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/language-server/src/lib/documents/utils.ts
Expand Up @@ -432,7 +432,8 @@ export function isInsideMoustacheTag(html: string, tagStart: number | null, posi
// TODO make this just check for '{'?
// Theoretically, someone could do {a < b} in a simple moustache tag
charactersBeforePosition.lastIndexOf('{#'),
charactersBeforePosition.lastIndexOf('{:')
charactersBeforePosition.lastIndexOf('{:'),
charactersBeforePosition.lastIndexOf('{@')
) > charactersBeforePosition.lastIndexOf('}')
);
} else {
Expand Down
12 changes: 12 additions & 0 deletions packages/language-server/test/lib/documents/parseHtml.test.ts
Expand Up @@ -37,6 +37,18 @@ describe('parseHtml', () => {
);
});

it('ignore binary operator inside @const', () => {
testRootElements(
parseHtml(
`{#if foo}
{@const bar = 1 << 2}
<Foo />
{/if}
<style></style>`
)
);
});

it('ignore less than operator inside control flow moustache', () => {
testRootElements(
parseHtml(
Expand Down

0 comments on commit 83d92c5

Please sign in to comment.