js-slang icon indicating copy to clipboard operation
js-slang copied to clipboard

Editor: Syntax highlighting is erroneous when string contains `&`

Open EmilyOng opened this issue 3 years ago • 3 comments

Note: There is no error in evaluation.

Reproduction

Not OK

  1. When the string is xxxx&xxx const foo = "a&b is parsed as variable.language and "; is parsed as string.

Screenshot 2021-08-19 at 8 58 37 PM

const foo = "a&b";
  1. When the string is xxxx&

Screenshot 2021-08-19 at 8 58 06 PM

const foo = "a&";

This string matches the variable.language regex possibly.

OK

Screenshot 2021-08-19 at 8 50 35 PM

const foo = "ab";

EmilyOng avatar Aug 19 '21 13:08 EmilyOng

This issue persists as of today.

martin-henz avatar Mar 30 '24 09:03 martin-henz

Should we just remove our custom js-slang syntax highlighting and use default JS one? I don't really see it as a "core" feature to maintain our own syntax highlighting rules (it's only going to get worse if we want to maintain highlighting rules for the other languages).

RichDom2185 avatar Mar 31 '24 03:03 RichDom2185

I think our syntax highlighting should reflect the focus on specific sublanguages, such as Source §1. Learners with prior knowledge are able to see quickly whether the feature they are using is included in the language.

martin-henz avatar Apr 01 '24 03:04 martin-henz