jskinner / DefaultPackages

Old bug tracker for Sublime Text's "Default Packages", e.g. bad syntax highlighting
http://web.archive.org/web/20150524043750/https://www.sublimetext.com/forum/viewtopic.php?f=2&t=12095
26 stars 2 forks source link

JavaScript: Syntax highlighting issue in ternary operator #177

Closed Tharit closed 8 years ago

Tharit commented 8 years ago

It seems like the syntax highlighting somehow looses the context of the ternary operator when a binary operator is used in the "if true" part. The last operand in the binary operator is then highlighted as if it was an object property (because of the following colon). This can be "fixed" by wrapping the binary operand in parenthesis.

Example:

// highlighted correctly
a = test ? a : b;
// highlighted correctly
a = test ? (a + b) : c;
// b is highlighted as if it was a property
a = test ? a + b : c;

screen shot 2016-02-19 at 15 41 21

Expected behaviour: "b" should never be highlighted as if it was a property.

FichteFoll commented 8 years ago

cc @wbond

wbond commented 8 years ago

This no longer occurs with the latest version at https://github.com/sublimehq/Packages. Please note the version there has not yet been shipped with a version of Sublime Text and will have some bugs until the next dev build of ST is out.

wbond commented 8 years ago

This was fixed a while ago and is part of the recent dev builds.