-
Notifications
You must be signed in to change notification settings - Fork 30.3k
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
No coloring of JavaScript in HTML/Razor/Handlebars #12750
Comments
It is caused by this rule in the JavaScript grammar:
{
"begin": "(?<=(?:'|\"|})>)",
"end": "(?=</)",
"name": "meta.jsx.children.js",
"patterns": [
{
"include": "#jsx-children"
}
]
} As soon as HTML includes JavaScript, the JavaScript grammar does a look behind and decides to enter into a jsx children state. |
To replicate my analysis please use:
Where test-bad is: <script type="text/javascript">
var x = 3;
console.log('hello world!');
</script> And test-good is: <script type="text/javascript" >
var x = 3;
console.log('hello world!');
</script> And then compare the two files. The first signficant diff points to the culprit: |
I suggest the following fix to the rule in Change the rule This means to still match all text with look-behind I am not a jsx expert, so I cannot say what's the impact of the change w.r.t. jsx |
@bpasero Please discuss in the standup and let me know if I can help further. |
JSX is a mix of Javascript and HTML. If there are JSX specific colors for javascript and html then those wont get applied. But writing JSX code with type So, this fix LGTM. |
@sandy081 you wanna take this? might need to review if our colorization tests fail with this change. |
@bpasero Sure I can take it up. Will check the tests too. |
After further investigation I am not in favor of doing the fix in I see this grammar is for But we can use this fix
I also checked all tests are passing. |
@sandy081 I was thinking that this place would be here: https://github.com/Microsoft/vscode/blob/master/extensions/html/syntaxes/html.json#L180 But I am not so sure anymore how the JS language gets pulled in. |
Ok it gets pulled in via TM import: https://github.com/Microsoft/vscode/blob/master/extensions/html/syntaxes/html.json#L232 |
@bpasero I went with the fix from @alexandrudima (made it more explicit). Pushed it as it is a regression and might make people unhappy. As this fix is a workaround and safer. See my previous comment for more details |
Testing #12100
I am not seeing coloring when typing JavaScript inside script tags in HTML/Razor/Handlebars.
Marking as important because I think this will make many people unhappy.
@alexandrudima fyi since @aeschli is out of office.
The text was updated successfully, but these errors were encountered: