Civet icon indicating copy to clipboard operation
Civet copied to clipboard

Broken syntax highlight in vscode with slash and @ symbols

Open unlessgames opened this issue 1 year ago • 0 comments

Somewhat related to #822 but I thought I'd make a separate issue. This is not a parse error per se, only the highlighter acting up while the code compiles.

Initially I wanted to suggest pasting this into vscode to see but (I assume the highlighter is using a patched coffee syntax) this is also an issue with coffee syntax below as well (except that in vscode the last line of this code is printed properly as a comment).

class Test
  public a : number = 2
  public b : number = 4
  @()
    @b = Math.pow (@b % @a) / @a, (10 / @a) / (@a)

class NotARegexp
  some : number
  fields : object
  to : RegExp
  misinterpretation : any
  @()
    // comments will still be inside regexp
    // @misinterpretation = "I am a comment that is highlighted as code"
    // ^ this @ sign will fix and break syntax highlighting at the same time

As is, the highlighter thinks it's a regexp starting from (@b % @a) / and it goes all the way until the @ sign breaks it around the end. If that @ is not there it's fairly easy to have the entire rest of a file stay highlighted as RegExp.

Try removing the parens around (@a) at the end of the Math.pow line, everything is fixed now.

Try removing @a from the (10 / @a) and replace with a literal like 20, also fixed.

Something about the slashes and parens and @ angers the syntax highlighter.

unlessgames avatar Nov 30 '23 02:11 unlessgames