mooz / js2-mode

Improved JavaScript editing mode for GNU Emacs
GNU General Public License v3.0
1.33k stars 186 forks source link

RegExp literal not highlighted after logical compound assignment #564

Closed MageJohn closed 3 years ago

MageJohn commented 3 years ago

I've found that a regexp literal is not highlighted as a string if it's on the right of one of the logical compound assignment operators, (logical AND, OR, and nullish assignment).

To reproduce

Paste this code into a js2-mode buffer:

foo &&= /bar/;
foo ||= /bar/;
foo ??= /bar/;

Expected behaviour

The /bar/ should be highlighted as a string on each line.

Actual behaviour

The slashes don't delimitate a string, and so the contents are highlighted by other rules.

Thanks for the great mode!

dgutov commented 3 years ago

Thanks for the report.

These are relatively new additions to the language, actually. So the main problem here is to start parsing those operators correctly. Then the regexps should right themselves automatically.

dgutov commented 3 years ago

This should do it.

MageJohn commented 3 years ago

Amazing, thanks for the quick fix!