Skip to content

Commit 3c25c09

Browse files
authored
[JavaScript] Fix comma after ternary expression (sublimehq#3986)
Fixes sublimehq#3985 This commit sets expression instead of expression-no-comma onto stack after ternary expressions, so they can appear in the middle of sequences.
1 parent d97fe6d commit 3c25c09

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

JavaScript/JavaScript.sublime-syntax

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1437,7 +1437,7 @@ contexts:
14371437
ternary-operator-expect-colon:
14381438
- match: ':'
14391439
scope: keyword.operator.ternary.js
1440-
set: expression-no-comma
1440+
set: expression
14411441
- include: else-pop
14421442

14431443
postfix-operators:

JavaScript/tests/syntax_test_js_control.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,33 @@
157157
// ^^^^^^^^^^^ meta.group
158158
// ^^ keyword.operator.word
159159

160+
for (a in b, c ? d: e, f(g())) {};
161+
// ^^^^ meta.for - meta.group
162+
// ^^^^^^^^^^^^^^^^^^^ meta.for meta.group - meta.function-call
163+
// ^^^^^^ meta.for meta.group meta.function-call
164+
// ^ meta.for meta.group - meta.function-call
165+
// ^ meta.for - meta.block - meta.group
166+
// ^^ meta.for meta.block
167+
// ^^^ keyword.control.loop.for
168+
// ^ punctuation.section.group.begin
169+
// ^ variable.other.readwrite
170+
// ^^ keyword.operator.word
171+
// ^ variable.other.readwrite
172+
// ^ keyword.operator.comma
173+
// ^ variable.other.readwrite
174+
// ^ keyword.operator.ternary
175+
// ^ variable.other.readwrite
176+
// ^ keyword.operator.ternary
177+
// ^ variable.other.readwrite
178+
// ^ keyword.operator.comma
179+
// ^ variable.function
180+
// ^ punctuation.section.group.begin
181+
// ^ variable.function
182+
// ^ punctuation.section.group.begin
183+
// ^^^ punctuation.section.group.end
184+
// ^ punctuation.section.block.begin
185+
// ^ punctuation.section.block.end
186+
160187
for (x of list) {}
161188
// ^^^^^^^^^^^^^^^^^^ meta.for
162189
// ^^^ keyword.control.loop.for

0 commit comments

Comments
 (0)