language-tools
language-tools copied to clipboard
<template> with a comment breaks VS Code highlighting
Describe the bug
Adding a comment tag inside a template tag breaks the highlight, in somewhat look-alike with #694. It might be an edge case.
Reproduction
- In VS Code,
- Create a template tag with an element inside.
- Comment out the element.
Sample svelte code:
<template>
<!--<div>
<p>A paragraph.</p>
</div>-->
</template>
Expected behaviour
The comment highlight should stop and the ending comment, and the </template> should be highlighted in pair with <template>.
System Info
- Extension: svelte-vscode-109.5.2
- IDE: VSCode 1.95.2
- OS: MacOS 15.1
Which package is the issue about?
Svelte for VS Code extension
Additional Information, eg. Screenshots
I don't have deep knowledge in tmLanguage files, but I skimming through svelte.tmLanguage.src.yaml I noticed the template tag is included in tags-lang.begin property, together with script and style (#L571).
Is there a specific reason why it needs to be taken care of? I noticed it highlights correctly if I remove the template part and rebuild the grammar file.
The reason for the lang check is because of <template lang="pug">. So the solution is probably similar to https://github.com/sveltejs/language-tools/issues/694 and some regex need to be tweaked.