visual-studio-codesyntax-highlighting

VSCode Fails String Literal Syntax Highlighting


I am working on a website with Visual Studio Code (v.1.95.2) but syntax highlighting seems to be messed up. This occurs when an HTML div element has an onclick attribute with JS code in the string. An example of this is shown below.

JS code highlighted wrong, with text after '//' in a string literal being seen as a comment

I have attempted disabling all extensions with code --disable-extensions and the syntax error still occurs.


Solution

  • caused by https://github.com/textmate/html.tmbundle/issues/113

    escape the 2nd slash \/ as a workaround
    <div onclick="window.open('https:/\/example.com')">

    fix