Skip to content

Commit 06d27e6

Browse files
committed
Better end regex for variable initializer
Fixes #471
1 parent 4fae4f5 commit 06d27e6

File tree

5 files changed

+84
-3
lines changed

5 files changed

+84
-3
lines changed

TypeScript.YAML-tmLanguage

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1080,7 +1080,7 @@ repository:
10801080
- begin: (?<!=|!)(=)(?!=)
10811081
beginCaptures:
10821082
'1': { name: keyword.operator.assignment.ts }
1083-
end: (?=[,);}\]])|(?=^\s*$)|(?<=\S)(?<!=)
1083+
end: (?=[,);}\]])|(?=^\s*$)|(?<=\S)(?<!=)(?=\s*$)
10841084
patterns:
10851085
- include: '#expression'
10861086

TypeScript.tmLanguage

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3272,7 +3272,7 @@
32723272
</dict>
32733273
</dict>
32743274
<key>end</key>
3275-
<string>(?=[,);}\]])|(?=^\s*$)|(?&lt;=\S)(?&lt;!=)</string>
3275+
<string>(?=[,);}\]])|(?=^\s*$)|(?&lt;=\S)(?&lt;!=)(?=\s*$)</string>
32763276
<key>patterns</key>
32773277
<array>
32783278
<dict>

TypeScriptReact.tmLanguage

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3276,7 +3276,7 @@
32763276
</dict>
32773277
</dict>
32783278
<key>end</key>
3279-
<string>(?=[,);}\]])|(?=^\s*$)|(?&lt;=\S)(?&lt;!=)</string>
3279+
<string>(?=[,);}\]])|(?=^\s*$)|(?&lt;=\S)(?&lt;!=)(?=\s*$)</string>
32803280
<key>patterns</key>
32813281
<array>
32823282
<dict>

tests/baselines/Issue471.baseline.txt

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
original file
2+
-----------------------------------
3+
const foo =
4+
true || `${'hello'}.txt`
5+
6+
function syntaxHighlightingIsBroken() {
7+
}
8+
-----------------------------------
9+
10+
Grammar: TypeScript.tmLanguage
11+
-----------------------------------
12+
>const foo =
13+
^^^^^
14+
source.ts meta.var.expr.ts storage.type.ts
15+
^
16+
source.ts meta.var.expr.ts
17+
^^^
18+
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.definition.variable.ts variable.other.readwrite.ts
19+
^
20+
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts
21+
^
22+
source.ts meta.var.expr.ts keyword.operator.assignment.ts
23+
^^
24+
source.ts meta.var.expr.ts
25+
> true || `${'hello'}.txt`
26+
^^^^
27+
source.ts meta.var.expr.ts
28+
^^^^
29+
source.ts meta.var.expr.ts constant.language.boolean.true.ts
30+
^
31+
source.ts meta.var.expr.ts
32+
^^
33+
source.ts meta.var.expr.ts keyword.operator.logical.ts
34+
^
35+
source.ts meta.var.expr.ts
36+
^
37+
source.ts meta.var.expr.ts string.template.ts punctuation.definition.string.template.begin.ts
38+
^^
39+
source.ts meta.var.expr.ts string.template.ts meta.template.expression.ts punctuation.definition.template-expression.begin.ts
40+
^
41+
source.ts meta.var.expr.ts string.template.ts meta.template.expression.ts string.quoted.single.ts punctuation.definition.string.begin.ts
42+
^^^^^
43+
source.ts meta.var.expr.ts string.template.ts meta.template.expression.ts string.quoted.single.ts
44+
^
45+
source.ts meta.var.expr.ts string.template.ts meta.template.expression.ts string.quoted.single.ts punctuation.definition.string.end.ts
46+
^
47+
source.ts meta.var.expr.ts string.template.ts meta.template.expression.ts punctuation.definition.template-expression.end.ts
48+
^^^^
49+
source.ts meta.var.expr.ts string.template.ts
50+
^
51+
source.ts meta.var.expr.ts string.template.ts punctuation.definition.string.template.end.ts
52+
^
53+
source.ts meta.var.expr.ts
54+
>
55+
^^
56+
source.ts
57+
>function syntaxHighlightingIsBroken() {
58+
^^^^^^^^
59+
source.ts meta.function.ts storage.type.function.ts
60+
^
61+
source.ts meta.function.ts
62+
^^^^^^^^^^^^^^^^^^^^^^^^^^
63+
source.ts meta.function.ts meta.definition.function.ts entity.name.function.ts
64+
^
65+
source.ts meta.function.ts meta.parameters.ts punctuation.definition.parameters.begin.ts
66+
^
67+
source.ts meta.function.ts meta.parameters.ts punctuation.definition.parameters.end.ts
68+
^
69+
source.ts meta.function.ts
70+
^
71+
source.ts meta.function.ts meta.block.ts punctuation.definition.block.ts
72+
^^
73+
source.ts meta.function.ts meta.block.ts
74+
>}
75+
^
76+
source.ts meta.function.ts meta.block.ts punctuation.definition.block.ts

tests/cases/Issue471.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
const foo =
2+
true || `${'hello'}.txt`
3+
4+
function syntaxHighlightingIsBroken() {
5+
}

0 commit comments

Comments
 (0)