cfmleditor / cfmleditor

An extension for Visual Studio Code to assist in development with CFML.
MIT License
22 stars 9 forks source link

JavaScript optional chaining operator “?.” causes syntax highlighting to mess up #33

Open JonathanWilkins1 opened 2 weeks ago

JonathanWilkins1 commented 2 weeks ago

I noticed twice now that whenever I use the optional chaining operator, the syntax highlighting turns all the JS code (inside a script tag) blue. It eventually fixes itself after a bunch more lines of code, but I’m not sure what exactly causes it to fix itself. Attached is a screenshot of where the messed up syntax highlighting starts after using ?.

image

ghedwards commented 2 weeks ago

Gave it a look but no luck tmLanguage files are like fine art, still considering a switch to tree sitter colouring

burncitiesburn commented 14 hours ago

This potentially might be fix. This is very lightly tested.

I found that adding ":" next to the use of the ?. operator fixed the parsing which lead me to looking at the ternary parser.

These are changes to the syntaxes/cfml.tmLanguage.json file

Screenshot 2024-11-28 at 12 15 31 PM Screenshot 2024-11-28 at 12 15 25 PM

Testing:

Before: Screenshot 2024-11-28 at 12 17 23 PM

After: Screenshot 2024-11-28 at 12 21 08 PM

I can push a PR with the change

ghedwards commented 13 hours ago

Negative look ahead? Looks good. Yes please submit a PR