Don't colorize nested tokens when the parent token has the CommandName TokenFlag #3994
Open
1 task done
Labels
Issue-Enhancement
It's a feature request.
Needs-Triage 🔍
It's a new issue that core contributor team needs to triage.
Prerequisites
Description of the new feature/enhancement
The PowerShell parser adds nested tokens when parsing command names with variables/subexpressions but don't actually evaluate them unless there's an invocation operator before the command.
This seems to be an intentional choice as noted in the parser code here: https://github.com/PowerShell/PowerShell/blob/master/src/System.Management.Automation/engine/parser/Parser.cs#L6352
The syntax highlighting in PSReadLine should make this fact clear to users by coloring the whole token as a command when there's no invocation operator.
You can see the current behavior here:
Proposed technical implementation details (optional)
When looping over the tokens, set a flag when an invocation operator is encountered and reset it whenever a non line continuation token is encountered. If a command token is encountered and the flag is set, scan the nested tokens, otherwise skip them and color the whole token with the command color.
The text was updated successfully, but these errors were encountered: