Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Syntax highlighting broken in 1.19.6 #803

Closed
mxj4 opened this issue Aug 14, 2023 · 4 comments · Fixed by #807
Closed

Syntax highlighting broken in 1.19.6 #803

mxj4 opened this issue Aug 14, 2023 · 4 comments · Fixed by #807

Comments

@mxj4
Copy link

mxj4 commented Aug 14, 2023

I installed pre-release version 1.19.6 and found the end of the %%raw() cannot be identified correctly, now everything starting from %%raw( share the same color:
image
This does not happen in 1.18.0:
image

@fhammerschmidt
Copy link
Member

fhammerschmidt commented Aug 15, 2023

The problem here is that JS syntax highlighting encounters no end symbol like a newline or a ;.

But this can be easily fixed in the following ways:

  1. Use regular strings:
%%raw("import './App.css'")
  1. Terminate the embedded JS with a semicolon
%%raw(`import './App.css';`)
  1. Or use multiple lines
%%raw(`
  import './App.css'
`)

TBH I did not really account for the single line syntax highlight when I implemented this feature, what should we do in that case? One workaround would be to just automatically format to one of the above suggestions, another one would be to only support JS syntax highlighting in multiline extension points (not sure if that is possible just with the tmlanguage grammar).

cc @zth @cristianoc

@zth
Copy link
Collaborator

zth commented Aug 16, 2023

Is the embedded string responsible for terminating? I'd expect the editor to highlight the embedded text up until some termination of the embedded string itself (`) in this case) but maybe that's not how it works?

@fhammerschmidt
Copy link
Member

fhammerschmidt commented Aug 16, 2023

My textmate knowledge is not good enough, but I imagine the embedded JS syntax finds no stop condition, and `) is very valid JS.

Edit: Supporting only multiline is actually easy. Just need to add a \n to the begin and end fields. found another fix, see below

@fhammerschmidt
Copy link
Member

Found a fix, I just added another single line pattern.

@zth zth closed this as completed in #807 Aug 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants