Skip to content

Commit

Permalink
[JavaScript] Fix comma after ternary expression (sublimehq#3986)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
deathaxe authored May 9, 2024
1 parent d97fe6d commit 3c25c09
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion JavaScript/JavaScript.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -1437,7 +1437,7 @@ contexts:
ternary-operator-expect-colon:
- match: ':'
scope: keyword.operator.ternary.js
set: expression-no-comma
set: expression
- include: else-pop

postfix-operators:
Expand Down
27 changes: 27 additions & 0 deletions JavaScript/tests/syntax_test_js_control.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,33 @@
// ^^^^^^^^^^^ meta.group
// ^^ keyword.operator.word

for (a in b, c ? d: e, f(g())) {};
// ^^^^ meta.for - meta.group
// ^^^^^^^^^^^^^^^^^^^ meta.for meta.group - meta.function-call
// ^^^^^^ meta.for meta.group meta.function-call
// ^ meta.for meta.group - meta.function-call
// ^ meta.for - meta.block - meta.group
// ^^ meta.for meta.block
// ^^^ keyword.control.loop.for
// ^ punctuation.section.group.begin
// ^ variable.other.readwrite
// ^^ keyword.operator.word
// ^ variable.other.readwrite
// ^ keyword.operator.comma
// ^ variable.other.readwrite
// ^ keyword.operator.ternary
// ^ variable.other.readwrite
// ^ keyword.operator.ternary
// ^ variable.other.readwrite
// ^ keyword.operator.comma
// ^ variable.function
// ^ punctuation.section.group.begin
// ^ variable.function
// ^ punctuation.section.group.begin
// ^^^ punctuation.section.group.end
// ^ punctuation.section.block.begin
// ^ punctuation.section.block.end

for (x of list) {}
// ^^^^^^^^^^^^^^^^^^ meta.for
// ^^^ keyword.control.loop.for
Expand Down

0 comments on commit 3c25c09

Please sign in to comment.