From 3c25c09be470ccfcab059b895bfffe8b0f806e3c Mon Sep 17 00:00:00 2001 From: deathaxe Date: Thu, 9 May 2024 18:10:36 +0200 Subject: [PATCH] [JavaScript] Fix comma after ternary expression (#3986) Fixes #3985 This commit sets expression instead of expression-no-comma onto stack after ternary expressions, so they can appear in the middle of sequences. --- JavaScript/JavaScript.sublime-syntax | 2 +- JavaScript/tests/syntax_test_js_control.js | 27 ++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/JavaScript/JavaScript.sublime-syntax b/JavaScript/JavaScript.sublime-syntax index 98c3362be8..15142511cd 100644 --- a/JavaScript/JavaScript.sublime-syntax +++ b/JavaScript/JavaScript.sublime-syntax @@ -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: diff --git a/JavaScript/tests/syntax_test_js_control.js b/JavaScript/tests/syntax_test_js_control.js index 1a98943566..9974d92a67 100644 --- a/JavaScript/tests/syntax_test_js_control.js +++ b/JavaScript/tests/syntax_test_js_control.js @@ -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