Closed msftrncs closed 3 years ago
I was able to get the desired result by editing my batchfile.cson (in VS CODE: batchfile.tmLanguage.json), removing line 474, and removing indention from 475. (different line numbers and syntax in the json file).
"variables": {
"patterns": [
{
"match": "(%)((~([fdpnxsatz]|\\$PATH:)*)?\\d|\\*)",
"captures": {
"1": {
"name": "punctuation.definition.variable.batchfile"
}
},
"name": "variable.parameter.batchfile"
},
{
"include": "#variable"
},
{
"include": "#variable_delayed_expansion"
}
]
},
included entire 'variables' section of VS Code's JSON file.
Also, looking at the REGEX, (%)((~([fdpnxsatz]|\\$PATH:)*)?\\d|\\*)
this seems to match too much. It allows '$PATH:' to appear multiple times, or for the expansion codes to be used after '$PATH:' which does not seem to be allowed by the Windows command interpreter, and also, at least Windows command interpreter accepts either case for either part. Seems maybe this was meant instead:
(%)(((?i)~[fdpnxsatz]*(\\$PATH:)?)?\\d|\\*)
EDIT: I did want to note that this does cause a failure to potentially try to match as a variable instead as a parameter, if there is another '%' further down the line to be the ending punctuation, which causes some weirdness if there are invalid variable name characters.
A batch parameter (percent (%) number) reference doesn't seem to be scoped correctly, and as such it doesn't get colored correctly in editors, such as VS Code (1.25.1 on Windows 10 1803)
Currently, it only ends up scoped in "punctuation.definition.variable.batchfile", unlike the normal variable '%', which gets included in both scopes, "punctuation.definition.variable.begin.batchfile" "variable.other.readwrite.batchfile"
I think the single % that is used to determine the scope "variable.parameter.batchfile" should be included in that scope, and then themes would color it like they do the rest of the parameter.
I was able to work around the issue of the % in front of a 'variable.parameter' not being scoped with the 'variable.parameter', by adding this to settings: