Skip to content

Commit 7166bf7

Browse files
author
Jordi Ramos
authored
Textmate: fix Razor expression classification inside of HTML tags (#7051)
* fix html-razor textmate - added textmate grammar to both razor and html (test) files so that we can correctly label razor components that are within html tags. We will need to update the html grammar used in razor as well - updated tests to reflect the desire behavior, note that we changed some of the classification from existing tests as they were not correctly labeling razor grammar in html tags either
1 parent 3d33d80 commit 7166bf7

File tree

6 files changed

+829
-112
lines changed

6 files changed

+829
-112
lines changed

src/razor/syntaxes/aspnetcorerazor.tmLanguage.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,16 @@
6464
}
6565
]
6666
},
67+
"implicit-or-explicit-expression": {
68+
"patterns": [
69+
{
70+
"include": "#explicit-razor-expression"
71+
},
72+
{
73+
"include": "#implicit-expression"
74+
}
75+
]
76+
},
6777
"escaped-transition": {
6878
"name": "constant.character.escape.razor.transition",
6979
"match": "@@"

src/razor/syntaxes/aspnetcorerazor.tmLanguage.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ repository:
3131
- include: '#optionally-transitioned-csharp-control-structures'
3232
- include: '#implicit-expression'
3333

34+
# a clause to combine the explicit and implicit razor expressions, used by the html grammar
35+
implicit-or-explicit-expression:
36+
patterns:
37+
- include: '#explicit-razor-expression'
38+
- include: '#implicit-expression'
39+
3440
escaped-transition:
3541
name: constant.character.escape.razor.transition
3642
match: '@@'

test/razorTests/Microsoft.AspNetCore.Razor.VSCode.Grammar.Test/embeddedGrammars/html.tmLanguage.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,9 @@
113113
},
114114
"name": "string.quoted.double.html",
115115
"patterns": [
116+
{
117+
"include": "text.aspnetcorerazor#implicit-or-explicit-expression"
118+
},
116119
{
117120
"include": "#entities"
118121
}
@@ -137,6 +140,9 @@
137140
},
138141
"name": "string.quoted.single.html",
139142
"patterns": [
143+
{
144+
"include": "text.aspnetcorerazor#implicit-or-explicit-expression"
145+
},
140146
{
141147
"include": "#entities"
142148
}
@@ -403,6 +409,9 @@
403409
},
404410
"name": "string.quoted.double.html",
405411
"patterns": [
412+
{
413+
"include": "text.aspnetcorerazor#implicit-or-explicit-expression"
414+
},
406415
{
407416
"include": "#entities"
408417
}
@@ -423,6 +432,9 @@
423432
},
424433
"name": "string.quoted.single.html",
425434
"patterns": [
435+
{
436+
"include": "text.aspnetcorerazor#implicit-or-explicit-expression"
437+
},
426438
{
427439
"include": "#entities"
428440
}

0 commit comments

Comments
 (0)