Skip to content

incorrect highlight of command with variable #836

@msftrncs

Description

@msftrncs

The syntax highlighting often gives the user the idea of what is going to happen, but in a few situations it seems to indicate the wrong things.

$a='goodbye'
hello$a # 'hello' is yellow, '$a' is green like its going to be expanded, but it doesn't
# instead, "The term 'hello$a' is not recognized as the name of a …" is returned.

I think it is safe to say, everything highlighted yellow, does not allow expansion

function hello () {echo $args}
$a= @{hello=3;goodbye=4}
$a[hello] # 'hello]' is yellow, like it could be a function call, but function calls seem not to be permitted in array index
$a[hello goodbye] # as you type, it looks like its going to be valid, but the prompt knows, its still red at the end.
$a[(hello goodbye)] # this is accepted

image

This seems to really confuse the syntax highlighting:

$a[(hello$b goodbye)]

image

Environment data

PS version: 6.1.1
PSReadline version: 2.0.0-beta3
os: 10.0.18298.1000 (WinBuild.160101.0800)
PS file version: 6.1.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions