intersystems / language-server

Repository for the VS Code Language Server
https://marketplace.visualstudio.com/items?itemName=intersystems.language-server
Other
16 stars 6 forks source link

Embedded JS #330

Closed Patresko closed 6 months ago

Patresko commented 6 months ago

Hello,

If I use embedded javascript syntax in the routine Im getting syntax highlighting error for <

&js< if (logoutTime === time) { location.reload(); } else if (time - logoutTime &lt; 10) { document.querySelector('[id*="textAfterBadge2"]').style.color = "red"; } else { document.querySelector('[id*="textAfterBadge2"]').style.color = "black"; };>

Maybe Im doing something wrong but within embedded javascript Im not able to use > or < so I replaced it with %lt or %gt

isc-bsaviano commented 6 months ago

@Patresko This isn't a bug, it's a consequence of a bad design choice when defining the Embedded JS syntax. You can't use the unclosed > in the code because that's the character that terminates the embedding. If you need to use > in the code, use Marker Syntax. That link is for Embedded SQL but the same rules apply for JS. For example, you code can be changed to:

&js@@<
if (logoutTime === time) {
            location.reload();
        } else if (time - logoutTime < 10) {
            document.querySelector('[id*="textAfterBadge2"]').style.color = "red";
        } else {
            document.querySelector('[id*="textAfterBadge2"]').style.color = "black";
        };>@@

and it will syntax color, compile and run correctly. You can't use &lt; escaping.