AL
AL copied to clipboard
`Case` inside `"Quoted Identifier"` is syntax-highlighted as `case` keyword and start of block. Ditto `begin`, `end`, etc.?
TSIA really:
Name: AL Language
Id: ms-dynamics-smb.al
Description: AL development tools for Dynamics 365 Business Central
Version: 9.0.615906
Publisher: Microsoft
VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=ms-dynamics-smb.al
Try enabling semantic highlighting https://youtu.be/cTc0kYFsAr0?t=312
It was already enabled:
Not sure whether this may make a difference, but set it up for AL Language only (as shown in the video with time stamp). And I am assuming that there is no other setting overriding your user setting?
Thanks, adding it in an "[AL]"
group means I actually get the highlighting, but it doesn't fix the issue with case
.
Trying a couple more, it looks like some other keywords are affected by this too, e.g. begin
and end
. Probably there is just missing code to stop trying to highlight anything specially within identifiers.
I can confirm this issue. I am having the exact same problem with Quted identifiers like "begin", "end", "case" etc.
It is there because with the latest version of VSCode the setting "editor.bracketPairColorization.enabled" is enabled by default. As a mitigation you should disable it in settings.
Sure, thanks - but is there a way that al.configuration.json
can define what a "quoted identifier"
is and then use "notIn"
to avoid highlighting such words within identifiers?
Since my duplicate issue (#7213) got closed, I will ask it here. Is there a plan to fix this issue in the near future?
Unfortunately, this is a bug in VSCode's bracket colorization feature and AL and we can't fix it on the AL side. VSCode has not considered the case that a bracket keyword may also be a word that is part of a language's syntax.
Begin and end are identified as brackets in al.configuration.json. From what I could figure out the colorization feature considers that only two kinds of code ranges should not have colorization on brackets, comments and strings. AL identifiers inside "" are neither of the two. At the same time, they are defined inside the grammar of the language which is why if you use a keyword inside a quoted identifier it will not appear highlighted.
There is no option to define that brackets should not be recognized in other syntax, so we can't override the behavior.
Here's a funny example where I've said that {"codeunit", "report"} is a bracket pair. VSCode is not smart enough to figure out that codeunit by itself is a language keyword and not a bracket:
Thus there are two options:
- Remove begin/end from brackets and thus remove support for bracket colors for these keywords altogether.
- Accept this bug can't be fixed on our side and file a bug on VSCode so that they don't highlight syntax elements defined in the language grammar.
Since "begin" and "end" are much more rarely used inside quoted identifier as compared to brackets, I think we can go with option 2 and depend on VSCode to make the feature a bit smarter.
@BazookaMusic Thanks for the investigation and write-up! Are the AL team going to file the bug with VSC?
I have created the issue here: https://github.com/microsoft/vscode/issues/167062
Many thanks!