michaelgmcd / vscode-language-babel

VSCode syntax highlighting for today's JavaScript
https://marketplace.visualstudio.com/items?itemName=mgmcdermott.vscode-language-babel
MIT License
131 stars 17 forks source link

Breaks highlighting HTML when a script tag omits semicolons #91

Closed kentcdodds closed 3 years ago

kentcdodds commented 3 years ago

All the info you need is in this issue: https://github.com/microsoft/vscode/issues/121577

I'll just copy over the contents of this comment:

image

Looks like it's exactly the same as my other screenshot.

What I find interesting is when I put my cursor on the closing </script> html tag or even the </html>, it incorrectly identifies language as "JavaScript"

image

However, if I add a semicolon, it correctly identifies it as HTML:

image

I would expect it to be able to identify it as the correct language regardless of the presence of the semicolon.

Once I switched off this plugin I no longer had these problems:

image

michaelgmcd commented 3 years ago

Hey Kent! Taking a look at this now. For some context, this issue (and ones like it) tend to get a bit hairy because this package is an "all-in-one" solution for what VSCode splits into "javascript" and "javascriptreact".

michaelgmcd commented 3 years ago

As an example, the code in test.html works without semicolons, but the snippet from your issue does not. Syntax highlighting is fun!

<html>
  <title>Title</title>
  <lang>en</lang>
  <body></body>
  <script>
    const rootElement = document.createElement('div')
    rootElement.id = 'root'
    document.body.append(rootElement)

    const helloWorldElement = document.createElement('div')
    helloWorldElement.textContent = 'Hello World'
    rootElement.append(helloWorldElement)
  </script>
</html>
michaelgmcd commented 3 years ago

Putting a pin in this for now, so using this thread for note-taking. The following simple cases seem to break the highlighting.:

<script>
  let foo
</script>
<script>
  foo.bar()
</script>

Like I mentioned, debugging this is pretty difficult, but narrowing it down to these cases is a start. There's an issue with a regex somewhere, it's just a matter of tracking it down.

michaelgmcd commented 3 years ago

Try out 0.0.35 Kent. The changes I made may have some side effects, but it looks good in my testing.

kentcdodds commented 3 years ago

Thanks! After disabling this extension for a while I actually realized I'm not sure I need this extension anymore 😅 But if I decide I do I'll try this out and let you know. Thanks Michael!