Description
Environment
- Editor and Version: VS Code: 1.31 Insiders / 1.30.1
- Your primary theme: Monokai Dimmed (modified)
Issue Description
In the following image and code, the if
is being scoped as 'keyword.control', as if it was valid to utilize an IF statement at this point. However it is not valid, and the code instead causes an error stating that The term 'if' is not recognized as the name …
No syntax error is reported by EditorServices either. PSReadLine however does indicate that the if
would be treated as a command instead of a keyword.
Screenshots
VS Code:
PSReadLine
(keywords would be green)
Expected Behavior
I would like to expect that this case would not receive 'keyword.control' scoping, so that I am not led to believe the given command might actually be correct. A quick attempt to correct this indicates that this will require some reorganization, because too many items are in the root patterns and not in the repository.
This also shows that there is more to argument mode vs. expression mode than I had originally thought. Control statements cannot always be used everywhere a command can be used. This also affects other limited scope keywords, such as in
, which is scoped as 'keyword.control' in more places than it should be.
Code Samples
'<?xml version="1.0"' + (if ($encoding) {' encoding="' + $encoding + '"'}) + '?>'
The correct code:
'<?xml version="1.0"' + $(if ($encoding) {' encoding="' + $encoding + '"'}) + '?>'