Skip to content

Commit 42d20a6

Browse files
committed
Fix the end of ternary expression
Fixes #244
1 parent 7fa318b commit 42d20a6

File tree

6 files changed

+149
-4
lines changed

6 files changed

+149
-4
lines changed

TypeScript.YAML-tmLanguage

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ repository:
142142

143143
ternary-expression:
144144
begin: (?=\?)
145-
end: (?=$|[;,}])
145+
end: (?=$|[;,})\]])
146146
patterns:
147147
- include: '#ternary-operator'
148148
- include: '#expression'

TypeScript.tmLanguage

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3400,7 +3400,7 @@
34003400
<key>begin</key>
34013401
<string>(?=\?)</string>
34023402
<key>end</key>
3403-
<string>(?=$|[;,}])</string>
3403+
<string>(?=$|[;,})\]])</string>
34043404
<key>patterns</key>
34053405
<array>
34063406
<dict>

TypeScriptReact.YAML-tmLanguage

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ repository:
146146

147147
ternary-expression:
148148
begin: (?=\?)
149-
end: (?=$|[;,}])
149+
end: (?=$|[;,})\]])
150150
patterns:
151151
- include: '#ternary-operator'
152152
- include: '#expression'

TypeScriptReact.tmLanguage

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3790,7 +3790,7 @@
37903790
<key>begin</key>
37913791
<string>(?=\?)</string>
37923792
<key>end</key>
3793-
<string>(?=$|[;,}])</string>
3793+
<string>(?=$|[;,})\]])</string>
37943794
<key>patterns</key>
37953795
<array>
37963796
<dict>

tests/baselines/Issue244.baseline.txt

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
original file
2+
-----------------------------------
3+
a.withLatestFrom(axis === 'x' ? initialX : initialY)
4+
.map(x => undefined)
5+
.switch()
6+
.publish().refCount();
7+
8+
const targetX = targetSideObs('x');
9+
const targetY = targetSideObs('y');
10+
-----------------------------------
11+
12+
>a.withLatestFrom(axis === 'x' ? initialX : initialY)
13+
^^^^^^^^^^^^^^^^
14+
source.ts
15+
^
16+
source.ts meta.brace.round.ts
17+
^^^^^
18+
source.ts
19+
^^^
20+
source.ts keyword.operator.comparison.ts
21+
^
22+
source.ts
23+
^
24+
source.ts string.quoted.single.ts punctuation.definition.string.begin.ts
25+
^
26+
source.ts string.quoted.single.ts
27+
^
28+
source.ts string.quoted.single.ts punctuation.definition.string.end.ts
29+
^
30+
source.ts
31+
^
32+
source.ts keyword.operator.ternary.ts
33+
^^^^^^^^^^
34+
source.ts
35+
^
36+
source.ts keyword.operator.ternary.ts
37+
^^^^^^^^^
38+
source.ts
39+
^
40+
source.ts meta.brace.round.ts
41+
^^
42+
source.ts
43+
> .map(x => undefined)
44+
^^^^^
45+
source.ts
46+
^
47+
source.ts meta.brace.round.ts
48+
^
49+
source.ts meta.arrow.ts variable.parameter.ts
50+
^
51+
source.ts meta.arrow.ts
52+
^^
53+
source.ts meta.arrow.ts storage.type.function.arrow.ts
54+
^
55+
source.ts meta.arrow.ts
56+
^^^^^^^^^
57+
source.ts constant.language.undefined.ts
58+
^
59+
source.ts meta.brace.round.ts
60+
^^
61+
source.ts
62+
> .switch()
63+
^^^^^^^^
64+
source.ts
65+
^
66+
source.ts meta.brace.round.ts
67+
^
68+
source.ts meta.brace.round.ts
69+
^^
70+
source.ts
71+
> .publish().refCount();
72+
^^^^^^^^^
73+
source.ts
74+
^
75+
source.ts meta.brace.round.ts
76+
^
77+
source.ts meta.brace.round.ts
78+
^^^^^^^^^
79+
source.ts
80+
^
81+
source.ts meta.brace.round.ts
82+
^
83+
source.ts meta.brace.round.ts
84+
^^^
85+
source.ts
86+
>
87+
^^
88+
source.ts
89+
>const targetX = targetSideObs('x');
90+
^^^^^
91+
source.ts meta.var.expr.ts storage.type.ts
92+
^
93+
source.ts meta.var.expr.ts
94+
^^^^^^^
95+
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts variable.other.readwrite.ts
96+
^
97+
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts
98+
^
99+
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts keyword.operator.assignment.ts
100+
^^^^^^^^^^^^^^
101+
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts
102+
^
103+
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.brace.round.ts
104+
^
105+
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts string.quoted.single.ts punctuation.definition.string.begin.ts
106+
^
107+
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts string.quoted.single.ts
108+
^
109+
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts string.quoted.single.ts punctuation.definition.string.end.ts
110+
^
111+
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.brace.round.ts
112+
^^^
113+
source.ts
114+
>const targetY = targetSideObs('y');
115+
^^^^^
116+
source.ts meta.var.expr.ts storage.type.ts
117+
^
118+
source.ts meta.var.expr.ts
119+
^^^^^^^
120+
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts variable.other.readwrite.ts
121+
^
122+
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts
123+
^
124+
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts keyword.operator.assignment.ts
125+
^^^^^^^^^^^^^^
126+
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts
127+
^
128+
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.brace.round.ts
129+
^
130+
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts string.quoted.single.ts punctuation.definition.string.begin.ts
131+
^
132+
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts string.quoted.single.ts
133+
^
134+
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts string.quoted.single.ts punctuation.definition.string.end.ts
135+
^
136+
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.brace.round.ts
137+
^^
138+
source.ts

tests/cases/Issue244.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
a.withLatestFrom(axis === 'x' ? initialX : initialY)
2+
.map(x => undefined)
3+
.switch()
4+
.publish().refCount();
5+
6+
const targetX = targetSideObs('x');
7+
const targetY = targetSideObs('y');

0 commit comments

Comments
 (0)