daaain / Handlebars

Fullest Handlebars.js templating support for Sublime Text 2 / 3. Also drives syntax colouring on Github and in Visual Studio Code. Install from: https://packagecontrol.io/packages/Handlebars.
MIT License
301 stars 48 forks source link

$(function {}) syntax highlighting failed #103

Open Cow258 opened 5 years ago

Cow258 commented 5 years ago

2019-05-07 12 11 19

Look at the gif.

syntax highlighting failed when "$(function () {" entered. syntax highlighting good when "$(function () {" commented

daaain commented 5 years ago

Hey,

Sorry for the slow response, I got as far as reproducing the issue on master, but haven't fixed it yet.

It seems the syntax highlighter gets very confused by the Javascript curly braces, you can make it do all sorts of weird things...

I'm not really sure why is this happening, but if you have time have a look and play with the Javascript script tag (https://github.com/daaain/Handlebars/blob/master/grammars/Handlebars.json#L148) and Handlebars type script tag (https://github.com/daaain/Handlebars/blob/master/grammars/Handlebars.json#L696) to see if detection can be improved.

There are a couple of files to test with, none of the currently supported features should break: https://github.com/daaain/Handlebars/tree/master/test

Cow258 commented 5 years ago

That's ok. Microsoft fixed it.

Cow258 commented 5 years ago

I tested on VSCode insider v1.35, issue has been fixed.

daaain commented 5 years ago

Hmm, that's really odd as their commit only pulled in the latest changes from this repo which only had an unrelated fix: https://github.com/microsoft/vscode/commit/45db52ba6bd211cecd03897caee0531350071721#diff-d15d8c6b4b1f6cdcdb925a0f62644dedR9

It's definitely still an issue in Sublime Text though where I tested, but since the way Javascript is handled is by using the existing language grammar definition in the editor I guess there can be inconsistencies.

Anyway, I think it's best to keep the issue open for now just to keep an eye on it.