Skip to content

Regular expressions aren't properly highlighted in certain scenarios #853

Open

Description

@a-ejs

in vscode 1.53.1

/foo/;
return /foo/;
throw /foo/;

yield* /foo/;
yield /foo/;
await /foo/;

export default /foo/;


if(_) /foo/;
else /foo/;

while(_) /foo/;

for(;;) /foo/;
for(_ in /foo/) /foo/;

with(_) /foo/;

do /foo/;
while(_);


void /foo/;
typeof /foo/;
/foo/ in /foo/;
/foo/ instanceof /foo/;
new /foo/;
!class extends /foo/ {};

/foo/[/foo/];
!/foo/;
~/foo/;
+/foo/;
-/foo/;
++/foo/;
--/foo/;
/foo/++;
/foo/--;

looks like this:

as can be seen, regular expressions aren't properly highlighted:

  • after throw/export default
  • after await/yield (but not yield*)
  • after while(), for(), with(), do, else (but not if())
  • after in/of (in for..in/for..of)
  • after void/typeof/new
  • as either operand of in/instanceof
  • after extends (in class)
  • after unary ++/--

worse yet, this can break the highlighting of surrounding code:

yield /[[]/;
if(1) {
	foo["bar"]();
	a: { break a; }
} else return 123;

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions