ProgerXP / Notepad2e

Word highlighting, simultaneous editing, split views, math evaluation, un/grep, comment reformatting, UAC elevation, complete regexps (PCRE), Lua lexers, DPI awareness and more (XP+)
Other
375 stars 52 forks source link

Highlight JS templates #207

Open ProgerXP opened 5 years ago

ProgerXP commented 5 years ago

JavaScript has a relatively new syntax for strings:

let str = `line1
${eval} line2
${`nested ${1+1}`} line3`

I.e. like 'str' and "str" but multiline and allowing expression interpolation via ${...} (and nested templates via this construct).

Need to add highlighting for such strings. However, Scintilla probably has this already, maybe we should just update our schemes? Also see #180.

cshnik commented 5 years ago

Fixed.

ProgerXP commented 5 years ago

Was this implemented from scratch or it's using Scintilla rules? Because highlighting rules are not correct:

cshnik commented 5 years ago

Here are the points:

  1. Scintilla's lexers are used when applying predefined highlighting rules.
  2. CPP lexer is used for Javascript scheme.
  3. Recent version of Scintilla still has no correct support of "JS template strings" feature: https://sourceforge.net/p/scintilla/feature-requests/1112/
ProgerXP commented 5 years ago

I see. Let's leave the rule enabled just in case later Scintilla devs get around to implementing proper template highlighting.