Skip to content

Commit 24165db

Browse files
committed
Fix Razor @{ } blocks
Also, the Razor bracket code makes more sense now.
1 parent 0ac56e9 commit 24165db

File tree

2 files changed

+37
-17
lines changed

2 files changed

+37
-17
lines changed

Razor/C# (Razor).sublime-syntax

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,8 @@ contexts:
2828
- include: Packages/HTML (C#)/Razor/Razor.sublime-syntax#comments
2929
- include: Packages/HTML (C#)/Razor/Razor.sublime-syntax#html
3030

31-
stray-braces:
32-
- match: (\})(\s*\n)?
33-
scope: meta.embedded.cs
34-
captures:
35-
1: punctuation.section.embedded.end.cs-razor
36-
2: meta.html-newline-after-csharp.cs-razor # used by indentation rules
37-
# - match: \}
38-
# scope: invalid.illegal.stray.cs
39-
40-
stray-brackets:
41-
- match: \]
42-
scope: invalid.illegal.stray.cs
43-
44-
stray-parens:
45-
- match: \)
31+
stray_close_bracket:
32+
- match: \]|\)
4633
scope: invalid.illegal.stray.cs
34+
- match: (?=})
35+
pop: 1

Razor/tests/syntax_test_cshtml.cshtml

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,13 +120,36 @@ else
120120
} *@
121121
<!-- ^^ comment.block punctuation.definition.comment -->
122122

123+
@{ }
124+
<!--^^^^^^ meta.embedded.cs -->
125+
<!--^^ punctuation.section.embedded.begin.cs-razor - source -->
126+
<!-- ^ source.cs.embedded.html -->
127+
<!-- ^ punctuation.section.embedded.end.cs-razor - source -->
128+
<!-- ^^ meta.html-newline-after-csharp.cs-razor - source -->
129+
123130
@{
124131
var quote = "The future depends on what you do today. - Mahatma Gandhi";
125-
<!-- ^^ source.cs.embedded -->
132+
<!--^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.embedded.cs source.cs.embedded.html -->
133+
<!-- ^^^^^ variable.other.cs -->
134+
<!-- ^ keyword.operator.assignment.variable.cs -->
135+
<!-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string.cs string.quoted.double.cs -->
136+
<!-- ^ punctuation.definition.string.begin.cs -->
137+
<!-- ^ punctuation.definition.string.end.cs -->
138+
<!-- ^ punctuation.terminator.statement.cs -->
126139
}
127140
<!-- ^ text.html - source -->
128141

129-
<p>@quote</p>
142+
<p>@quote</p>
143+
<!--^^^ meta.tag.block.any.html -->
144+
<!--^ punctuation.definition.tag.begin.html -->
145+
<!-- ^ entity.name.tag.block.any.html -->
146+
<!-- ^ punctuation.definition.tag.end.html -->
147+
<!-- ^ punctuation.section.embedded.line.cs-razor -->
148+
<!-- ^^^^^ source.cs.embedded.html variable.other.cs -->
149+
<!-- ^^^^ meta.tag.block.any.html -->
150+
<!-- ^^ punctuation.definition.tag.begin.html -->
151+
<!-- ^ entity.name.tag.block.any.html -->
152+
<!-- ^ punctuation.definition.tag.end.html -->
130153

131154
@{
132155
quote = "Hate cannot drive out hate, only love can do that. - Martin Luther King, Jr.";
@@ -165,9 +188,17 @@ finally
165188

166189
@{
167190
/* C# comment */
191+
<!--^^^^^^^^^^^^^^^^ meta.embedded.cs source.cs.embedded.html -->
192+
<!--^^^^^^^^^^^^^^^^ comment.block.cs -->
193+
<!--^^ punctuation.definition.comment.begin.cs -->
194+
<!-- ^^ punctuation.definition.comment.end.cs -->
168195
// Another C# comment
196+
<!--^^^^^^^^^^^^^^^^^^^^^ meta.embedded.cs source.cs.embedded.html -->
197+
<!--^^^^^^^^^^^^^^^^^^^^^ comment.line.double-slash.cs -->
198+
<!--^^ punctuation.definition.comment.cs -->
169199
}
170200
<!-- HTML comment -->
201+
<!-- ^^^^^^^^^^^^^^^^ comment.block.html -->
171202

172203

173204
@functions {

0 commit comments

Comments
 (0)