Skip to content

Commit

Permalink
Textmate: fix Razor expression classification inside of HTML tags (#7051
Browse files Browse the repository at this point in the history
)

* 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
  • Loading branch information
jordi1215 committed Apr 16, 2024
1 parent 3d33d80 commit 7166bf7
Show file tree
Hide file tree
Showing 6 changed files with 829 additions and 112 deletions.
10 changes: 10 additions & 0 deletions src/razor/syntaxes/aspnetcorerazor.tmLanguage.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,16 @@
}
]
},
"implicit-or-explicit-expression": {
"patterns": [
{
"include": "#explicit-razor-expression"
},
{
"include": "#implicit-expression"
}
]
},
"escaped-transition": {
"name": "constant.character.escape.razor.transition",
"match": "@@"
Expand Down
6 changes: 6 additions & 0 deletions src/razor/syntaxes/aspnetcorerazor.tmLanguage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ repository:
- include: '#optionally-transitioned-csharp-control-structures'
- include: '#implicit-expression'

# a clause to combine the explicit and implicit razor expressions, used by the html grammar
implicit-or-explicit-expression:
patterns:
- include: '#explicit-razor-expression'
- include: '#implicit-expression'

escaped-transition:
name: constant.character.escape.razor.transition
match: '@@'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@
},
"name": "string.quoted.double.html",
"patterns": [
{
"include": "text.aspnetcorerazor#implicit-or-explicit-expression"
},
{
"include": "#entities"
}
Expand All @@ -137,6 +140,9 @@
},
"name": "string.quoted.single.html",
"patterns": [
{
"include": "text.aspnetcorerazor#implicit-or-explicit-expression"
},
{
"include": "#entities"
}
Expand Down Expand Up @@ -403,6 +409,9 @@
},
"name": "string.quoted.double.html",
"patterns": [
{
"include": "text.aspnetcorerazor#implicit-or-explicit-expression"
},
{
"include": "#entities"
}
Expand All @@ -423,6 +432,9 @@
},
"name": "string.quoted.single.html",
"patterns": [
{
"include": "text.aspnetcorerazor#implicit-or-explicit-expression"
},
{
"include": "#entities"
}
Expand Down

0 comments on commit 7166bf7

Please sign in to comment.