Skip to content

Commit 923f835

Browse files
authored
fix(vscode): correct highlighting on tag starting with template (#4770)
1 parent 69be985 commit 923f835

File tree

3 files changed

+49
-4
lines changed

3 files changed

+49
-4
lines changed

extensions/vscode/syntaxes/vue.tmLanguage.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -856,7 +856,7 @@
856856
]
857857
},
858858
"template-tag-1": {
859-
"begin": "(<)(template)\\b(>)",
859+
"begin": "(<)(template[a-zA-Z0-9:-]*)\\b(>)",
860860
"beginCaptures": {
861861
"1": {
862862
"name": "punctuation.definition.tag.begin.html.vue"
@@ -878,7 +878,7 @@
878878
"patterns": [
879879
{
880880
"begin": "\\G",
881-
"end": "(?=/>)|((</)(template)\\b)",
881+
"end": "(?=/>)|((</)(template[a-zA-Z0-9:-]*)\\b)",
882882
"endCaptures": {
883883
"2": {
884884
"name": "punctuation.definition.tag.begin.html.vue"
@@ -897,7 +897,7 @@
897897
]
898898
},
899899
"template-tag-2": {
900-
"begin": "(<)(template)\\b",
900+
"begin": "(<)(template[a-zA-Z0-9:-]*)\\b",
901901
"beginCaptures": {
902902
"1": {
903903
"name": "punctuation.definition.tag.begin.html.vue"
@@ -916,7 +916,7 @@
916916
"patterns": [
917917
{
918918
"begin": "\\G",
919-
"end": "(?=/>)|((</)(template)\\b)",
919+
"end": "(?=/>)|((</)(template[a-zA-Z0-9:-]*)\\b)",
920920
"endCaptures": {
921921
"2": {
922922
"name": "punctuation.definition.tag.begin.html.vue"

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

+39
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,45 @@ exports[`grammar > script-tag-in-script.vue 1`] = `
363363
#^ source.vue"
364364
`;
365365
366+
exports[`grammar > tag-starts-with-template.vue 1`] = `
367+
"><template>
368+
#^ source.vue punctuation.definition.tag.begin.html.vue
369+
# ^^^^^^^^ source.vue entity.name.tag.template.html.vue
370+
# ^ source.vue meta.tag-stuff punctuation.definition.tag.end.html.vue
371+
> <template-foo></template-foo>
372+
#^ source.vue text.html.derivative
373+
# ^ source.vue text.html.derivative meta.template-tag.start punctuation.definition.tag.begin.html.vue
374+
# ^^^^^^^^^^^^ source.vue text.html.derivative meta.template-tag.start entity.name.tag.template-foo.html.vue
375+
# ^ source.vue text.html.derivative meta.template-tag.start punctuation.definition.tag.end.html.vue
376+
# ^^ source.vue text.html.derivative meta.template-tag.start meta.template-tag.end punctuation.definition.tag.begin.html.vue
377+
# ^^^^^^^^^^^^ source.vue text.html.derivative meta.template-tag.start meta.template-tag.end entity.name.tag.template-foo.html.vue
378+
# ^ source.vue text.html.derivative meta.template-tag.start punctuation.definition.tag.end.html.vue
379+
> <template:bar></template:bar>
380+
#^ source.vue text.html.derivative
381+
# ^ source.vue text.html.derivative meta.template-tag.start punctuation.definition.tag.begin.html.vue
382+
# ^^^^^^^^^^^^ source.vue text.html.derivative meta.template-tag.start entity.name.tag.template:bar.html.vue
383+
# ^ source.vue text.html.derivative meta.template-tag.start punctuation.definition.tag.end.html.vue
384+
# ^^ source.vue text.html.derivative meta.template-tag.start meta.template-tag.end punctuation.definition.tag.begin.html.vue
385+
# ^^^^^^^^^^^^ source.vue text.html.derivative meta.template-tag.start meta.template-tag.end entity.name.tag.template:bar.html.vue
386+
# ^ source.vue text.html.derivative meta.template-tag.start punctuation.definition.tag.end.html.vue
387+
> <template-foo />
388+
#^ source.vue text.html.derivative
389+
# ^ source.vue text.html.derivative meta.template-tag.start punctuation.definition.tag.begin.html.vue
390+
# ^^^^^^^^^^^^ source.vue text.html.derivative meta.template-tag.start entity.name.tag.template-foo.html.vue
391+
# ^ source.vue text.html.derivative meta.template-tag.start meta.template-tag.end meta.tag-stuff
392+
# ^^ source.vue text.html.derivative meta.template-tag.start punctuation.definition.tag.end.html.vue
393+
> <template:bar />
394+
#^ source.vue text.html.derivative
395+
# ^ source.vue text.html.derivative meta.template-tag.start punctuation.definition.tag.begin.html.vue
396+
# ^^^^^^^^^^^^ source.vue text.html.derivative meta.template-tag.start entity.name.tag.template:bar.html.vue
397+
# ^ source.vue text.html.derivative meta.template-tag.start meta.template-tag.end meta.tag-stuff
398+
# ^^ source.vue text.html.derivative meta.template-tag.start punctuation.definition.tag.end.html.vue
399+
></template>
400+
#^^ source.vue punctuation.definition.tag.begin.html.vue
401+
# ^^^^^^^^ source.vue entity.name.tag.template.html.vue
402+
# ^ source.vue punctuation.definition.tag.end.html.vue"
403+
`;
404+
366405
exports[`grammar > template-expression.vue 1`] = `
367406
"><template>
368407
#^ source.vue punctuation.definition.tag.begin.html.vue
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<template>
2+
<template-foo></template-foo>
3+
<template:bar></template:bar>
4+
<template-foo />
5+
<template:bar />
6+
</template>

0 commit comments

Comments
 (0)