sublimehq / Packages

Syntax highlighting files shipped with Sublime Text and Sublime Merge
https://sublimetext.com
Other
2.95k stars 587 forks source link

[JavaScript] Fix regression with ternary operators #4025

Closed deathaxe closed 1 month ago

deathaxe commented 1 month ago

This PR fixes a regression, introduced by #3986, which breaks syntax highlighting in objects, as comma is no longer consumed as key-value-pair separator.

It's not the ternary expression, which allows commas, but the for statement, which allows multiple expressions, separated by comma after in keyword.

for (var in <expr>, <expr>, ...)

expr: any valid expression, maybe ternary, maybe function-call

The change to ternary expressions is reverted and for-condition context is modified instead to allow multiple expressions after in keyword.

Also scope ; invalid if there are too many.