Description
Prerequisites
- Write a descriptive title.
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.