diff --git a/extensions/vscode/syntaxes/vue.tmLanguage.json b/extensions/vscode/syntaxes/vue.tmLanguage.json
index e7e82a915d..b0d1cab30e 100644
--- a/extensions/vscode/syntaxes/vue.tmLanguage.json
+++ b/extensions/vscode/syntaxes/vue.tmLanguage.json
@@ -690,7 +690,7 @@
]
},
{
- "begin": "(template)\\b",
+ "begin": "(template)(?=\\s|\\/?>)",
"beginCaptures": {
"1": {
"name": "entity.name.tag.$1.html.vue"
@@ -711,7 +711,7 @@
},
{
"begin": "(?<=>)",
- "end": "(?=<\\/template\\b)",
+ "end": "(?=<\\/template[\\s>])",
"name": "text.html.derivative",
"patterns": [
{
@@ -722,7 +722,7 @@
]
},
{
- "begin": "(script)\\b",
+ "begin": "(script)(?=\\s|\\/?>)",
"beginCaptures": {
"1": {
"name": "entity.name.tag.$1.html.vue"
@@ -743,7 +743,7 @@
},
{
"begin": "(?<=>)",
- "end": "(?=<\\/script\\b)",
+ "end": "(?=<\\/script[\\s>])",
"name": "source.js",
"patterns": [
{
@@ -754,7 +754,7 @@
]
},
{
- "begin": "(style)\\b",
+ "begin": "(style)(?=\\s|\\/?>)",
"beginCaptures": {
"1": {
"name": "entity.name.tag.$1.html.vue"
@@ -775,7 +775,7 @@
},
{
"begin": "(?<=>)",
- "end": "(?=<\\/style\\b)",
+ "end": "(?=<\\/style[\\s>])",
"name": "source.css",
"patterns": [
{
@@ -872,7 +872,7 @@
"patterns": [
{
"begin": "\\G",
- "end": "(?=/>)|(()(template)\\b)",
+ "end": "(?=/>)|(()(template)(?=[\\s>]))",
"endCaptures": {
"2": {
"name": "punctuation.definition.tag.begin.html.vue"
@@ -891,7 +891,7 @@
]
},
"template-tag-2": {
- "begin": "(<)(template)\\b",
+ "begin": "(<)(template)(?=\\s|\\/?>)",
"beginCaptures": {
"1": {
"name": "punctuation.definition.tag.begin.html.vue"
@@ -910,7 +910,7 @@
"patterns": [
{
"begin": "\\G",
- "end": "(?=/>)|(()(template)\\b)",
+ "end": "(?=/>)|(()(template)(?=[\\s>]))",
"endCaptures": {
"2": {
"name": "punctuation.definition.tag.begin.html.vue"
diff --git a/extensions/vscode/tests/__snapshots__/grammar.spec.ts.snap b/extensions/vscode/tests/__snapshots__/grammar.spec.ts.snap
index 5769077f2d..c2cdba8db1 100644
--- a/extensions/vscode/tests/__snapshots__/grammar.spec.ts.snap
+++ b/extensions/vscode/tests/__snapshots__/grammar.spec.ts.snap
@@ -345,6 +345,33 @@ exports[`grammar > script-tag-in-script.vue 1`] = `
#^ source.vue"
`;
+exports[`grammar > tag-starts-with-template.vue 1`] = `
+">
+#^ source.vue punctuation.definition.tag.begin.html.vue
+# ^^^^^^^^ source.vue entity.name.tag.template.html.vue
+# ^ source.vue meta.tag-stuff punctuation.definition.tag.end.html.vue
+>
+#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.vue text.html.derivative
+>
+#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.vue text.html.derivative
+>
+#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.vue text.html.derivative
+> {{ 0 }}
+#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.vue text.html.derivative
+>
+#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.vue text.html.derivative
+>
+#^^^^^^^^^^^^^^^^^^^^^ source.vue text.html.derivative
+>
+#^^^^^^^^^^^^^^^^^^^^ source.vue text.html.derivative
+>
+#^^ source.vue punctuation.definition.tag.begin.html.vue
+# ^^^^^^^^ source.vue entity.name.tag.template.html.vue
+# ^ source.vue punctuation.definition.tag.end.html.vue
+>
+#^ source.vue"
+`;
+
exports[`grammar > template-expression.vue 1`] = `
">
#^ source.vue punctuation.definition.tag.begin.html.vue
diff --git a/extensions/vscode/tests/grammarFixtures/tag-starts-with-template.vue b/extensions/vscode/tests/grammarFixtures/tag-starts-with-template.vue
new file mode 100644
index 0000000000..6ef436e833
--- /dev/null
+++ b/extensions/vscode/tests/grammarFixtures/tag-starts-with-template.vue
@@ -0,0 +1,9 @@
+
+
+
+
+ {{ 0 }}
+
+
+
+