Skip to content

Commit d937a84

Browse files
serkodevKazariEX
andauthored
fix(vscode): correct highlighting of tags starting with template (#5755)
Co-authored-by: KazariEX <[email protected]>
1 parent 3e57535 commit d937a84

File tree

3 files changed

+45
-9
lines changed

3 files changed

+45
-9
lines changed

extensions/vscode/syntaxes/vue.tmLanguage.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -690,7 +690,7 @@
690690
]
691691
},
692692
{
693-
"begin": "(template)\\b",
693+
"begin": "(template)(?=\\s|\\/?>)",
694694
"beginCaptures": {
695695
"1": {
696696
"name": "entity.name.tag.$1.html.vue"
@@ -711,7 +711,7 @@
711711
},
712712
{
713713
"begin": "(?<=>)",
714-
"end": "(?=<\\/template\\b)",
714+
"end": "(?=<\\/template[\\s>])",
715715
"name": "text.html.derivative",
716716
"patterns": [
717717
{
@@ -722,7 +722,7 @@
722722
]
723723
},
724724
{
725-
"begin": "(script)\\b",
725+
"begin": "(script)(?=\\s|\\/?>)",
726726
"beginCaptures": {
727727
"1": {
728728
"name": "entity.name.tag.$1.html.vue"
@@ -743,7 +743,7 @@
743743
},
744744
{
745745
"begin": "(?<=>)",
746-
"end": "(?=<\\/script\\b)",
746+
"end": "(?=<\\/script[\\s>])",
747747
"name": "source.js",
748748
"patterns": [
749749
{
@@ -754,7 +754,7 @@
754754
]
755755
},
756756
{
757-
"begin": "(style)\\b",
757+
"begin": "(style)(?=\\s|\\/?>)",
758758
"beginCaptures": {
759759
"1": {
760760
"name": "entity.name.tag.$1.html.vue"
@@ -775,7 +775,7 @@
775775
},
776776
{
777777
"begin": "(?<=>)",
778-
"end": "(?=<\\/style\\b)",
778+
"end": "(?=<\\/style[\\s>])",
779779
"name": "source.css",
780780
"patterns": [
781781
{
@@ -872,7 +872,7 @@
872872
"patterns": [
873873
{
874874
"begin": "\\G",
875-
"end": "(?=/>)|((</)(template)\\b)",
875+
"end": "(?=/>)|((</)(template)(?=[\\s>]))",
876876
"endCaptures": {
877877
"2": {
878878
"name": "punctuation.definition.tag.begin.html.vue"
@@ -891,7 +891,7 @@
891891
]
892892
},
893893
"template-tag-2": {
894-
"begin": "(<)(template)\\b",
894+
"begin": "(<)(template)(?=\\s|\\/?>)",
895895
"beginCaptures": {
896896
"1": {
897897
"name": "punctuation.definition.tag.begin.html.vue"
@@ -910,7 +910,7 @@
910910
"patterns": [
911911
{
912912
"begin": "\\G",
913-
"end": "(?=/>)|((</)(template)\\b)",
913+
"end": "(?=/>)|((</)(template)(?=[\\s>]))",
914914
"endCaptures": {
915915
"2": {
916916
"name": "punctuation.definition.tag.begin.html.vue"

extensions/vscode/tests/__snapshots__/grammar.spec.ts.snap

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,33 @@ exports[`grammar > script-tag-in-script.vue 1`] = `
345345
#^ source.vue"
346346
`;
347347
348+
exports[`grammar > tag-starts-with-template.vue 1`] = `
349+
"><template>
350+
#^ source.vue punctuation.definition.tag.begin.html.vue
351+
# ^^^^^^^^ source.vue entity.name.tag.template.html.vue
352+
# ^ source.vue meta.tag-stuff punctuation.definition.tag.end.html.vue
353+
> <template-foo></template-foo>
354+
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.vue text.html.derivative
355+
> <template:foo></template:foo>
356+
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.vue text.html.derivative
357+
> <template-foo bar></template-foo>
358+
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.vue text.html.derivative
359+
> <template-foo>{{ 0 }}</template-foo>
360+
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.vue text.html.derivative
361+
> <template.foo[0].bar></template.foo[0].bar>
362+
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.vue text.html.derivative
363+
> <template-foo />
364+
#^^^^^^^^^^^^^^^^^^^^^ source.vue text.html.derivative
365+
> <template-foo/>
366+
#^^^^^^^^^^^^^^^^^^^^ source.vue text.html.derivative
367+
></template>
368+
#^^ source.vue punctuation.definition.tag.begin.html.vue
369+
# ^^^^^^^^ source.vue entity.name.tag.template.html.vue
370+
# ^ source.vue punctuation.definition.tag.end.html.vue
371+
>
372+
#^ source.vue"
373+
`;
374+
348375
exports[`grammar > template-expression.vue 1`] = `
349376
"><template>
350377
#^ source.vue punctuation.definition.tag.begin.html.vue
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<template>
2+
<template-foo></template-foo>
3+
<template:foo></template:foo>
4+
<template-foo bar></template-foo>
5+
<template-foo>{{ 0 }}</template-foo>
6+
<template.foo[0].bar></template.foo[0].bar>
7+
<template-foo />
8+
<template-foo/>
9+
</template>

0 commit comments

Comments
 (0)