Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

$test:/ - colon is not being parsed correctly on string #192

Open
DanielSSilva opened this issue Dec 21, 2019 · 3 comments
Open

$test:/ - colon is not being parsed correctly on string #192

DanielSSilva opened this issue Dec 21, 2019 · 3 comments

Comments

@DanielSSilva
Copy link

Environment

  • Editor and Version (VS Code, Atom, Sublime): vscode 1.42.0-insiders
  • Your primary theme: Monokai

Issue Description

From my tests, this seems to only happen if the colon is followed by some sort of special character such as - @ / etc

Screenshots

image

Expected Behavior

It should parse correctly, like this (taken from windows powershell). Notice that the colon is green, since it "belongs" to the variable:
image

Code Samples

$ip = "192.1.1.1"
###not being parsed###
"pi@$ip:/home/pi/PowerShell_IoT/"
"pi@$ip:-home/pi/PowerShell_IoT/"
"pi@$ip:@home/pi/PowerShell_IoT/"
###parsed correctly when without special characters###
"pi@$ip:home/pi/PowerShell_IoT/"
###correct syntax###
"pi@$ip`:/home/pi/PowerShell_IoT/"```
@msftrncs
Copy link
Contributor

There might be a little confusion of what should be displayed here.

$ip: is not a valid variable reference.

Here is your code on PR #156 when using a theme that highlights invalid constructs in bright red.

image

Note the squiggles from PSSA indicating the variable references are invalid.

Notice that the colon is green, since it "belongs" to the variable:

But notice that the prompt > is red, indicating that something is wrong with the command.

The correct syntax is actually:

"pi@${ip}:/home/pi/PowerShell_IoT/"

image

@DanielSSilva
Copy link
Author

Yap, I know that it is an invalid reference, but so is $ip:@ (I think).
Because I don't use PowerShell that much, I forgot that $variable: is reserved for scope, but because it was not highlighted as an error, it took me a while to understand what was wrong.
So I think that what you showed with a theme that highlights is what's expected. Which theme is that btw?

@msftrncs
Copy link
Contributor

msftrncs commented Dec 23, 2019

The theme in my images is a modified Monokai Dimmed, https://github.com/msftrncs/theme-monokai-less-dimmed. Monokai Dimmed does provide an invalid scope.

What is more important is the work I put in to PR #156 so that the invalid variable reference was scoped as invalid. Currently, the variable constructs in the current repository requires a valid character after the ':' in order to be part of the scope or drive reference, and might not even consider any additional colons as valid at all, so you might have a point there. This appears to be what issue #49 was about. I've been running with PR #156 for so long I've forgotten this was an issue.

In $ip:@, when contained within an expandable string, only the $ip: would be considered invalid, as the @ would be considered just part of the string. @ is not allowed in a bare variable reference, but is only considered for a splatting operation if it is the first character in a bare-word argument.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants