Skip to content

Holding Ctrl+Shift+Left/Right Arrow doesn't work in the variable selection #1358

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

Closed
aliasadidev opened this issue Jun 10, 2018 · 19 comments
Closed

Comments

@aliasadidev
Copy link

aliasadidev commented Jun 10, 2018

System Details

  • Operating system name and version: Win 10
  • VS Code version: 1.23.1
  • PowerShell extension version: 1.7.0.0

Issue Description

I can't select a variable with CTRL+SHIFT+LEFT/RIGHT ARROW, it doesn't continue highlighting a $ character.

kind regard :-)

@rjmholt
Copy link
Contributor

rjmholt commented Jun 11, 2018

Hi @Ali64B, would you be able to provide a small reproducible scenario? Like a code snippet we could try to reproduce this with? And if the behaviour is more visual, you should be able to upload a GIF here that demonstrates it.

@aliasadidev
Copy link
Author

Variable in PowerShell must start with “$” and since “$” has been introduced as white space character there is no way to select the whole variable name with one time using CTRL+SHIFT+LEFT/RIGHT ARROW.

@TylerLeonhardt
Copy link
Member

Hey @Ali64B, can you elaborate on what you mean by

since "$" has been introduced as a white space character

@rjmholt
Copy link
Contributor

rjmholt commented Jun 14, 2018

It looks like $ should be included in our "word" definition already:

wordPattern: /(-?\d*\.\d\w*)|([^\`\~\!\@\#\%\^\&\*\(\)\=\+\[\{\]\}\\\|\;\'\"\,\.\<\>\/\?\s]+)/g,

@TylerLeonhardt
Copy link
Member

I'd be interested in knowing if this issue repros without the PowerShell extension installed. If it does repro, this could be an issue we need to bring up with VSCode itself on how we can fix this at their level.

@aliasadidev
Copy link
Author

Hi @rjmholt.
That is exactly what I told.

@rjmholt
Copy link
Contributor

rjmholt commented Jun 17, 2018

@Ali64B No I mean, that regex defines "words" in PowerShell, and already includes $variable, so that should already work (but evidently doesn't).

Is there another place where you're saying we're defining whitespace characters?

Otherwise, it may be a change we need to make in the VSCode code, although I'm not sure where.

So to be clear, I'm not sure what is causing this bug, but I think the line I linked above is already correct.

@aliasadidev
Copy link
Author

aliasadidev commented Jun 17, 2018

@rjmholt This issue is not fixed yet Allow language extensions to override editor.wordSeparators

@rjmholt
Copy link
Contributor

rjmholt commented Jun 17, 2018

Good find! That looks like it might be the part in question. That means users can override that setting then yes??

@aliasadidev
Copy link
Author

Yes , you're right.

@rjmholt
Copy link
Contributor

rjmholt commented Jun 17, 2018

So I'm thinking we should come up with a good regex for PowerShell and post it here (so that anyone can use it). And then work out if there's a way for us to set that setting when the extension is running.

I've also followed up on that issue you linked.

@TylerLeonhardt
Copy link
Member

@Ali64B you might want to take a look at this as a work around.

microsoft/vscode#2036 (comment)

@TylerLeonhardt
Copy link
Member

, "editor.wordSeparators": "`~!@#%^&*()-=+[{]}\\|;:'\",.<>/?"

@TylerLeonhardt
Copy link
Member

Since we don't have this at the language level yet, I'm gonna go ahead and close this in favor of the VSCode issue.

Let me know if you think otherwise!

@rkeithhill
Copy link
Contributor

rkeithhill commented Jun 19, 2018

So I tried that "editor.wordSeparators" for a while and decided I didn't like it. When you double-click to select a variable $foo it will not highlight any instances of the form ${foo} which is common inside double-quoted strings. I'm going back to the default value for this setting.

@rjmholt
Copy link
Contributor

rjmholt commented Jun 20, 2018

Does this work better?

"editor.wordSeparators": "`~!@#%^&*()-=+[}\\|;:'\",.<>/?"

Also, I'm annoyed its a just a character list rather than a regex or something... I thought the "word" definition was supposed to deal with this.

@rkeithhill
Copy link
Contributor

Still leaves the ${var} form unselected:

image

And you still have the issue of the whole variable not being selected when you specify the scope e.g,: $global:foo = 1.

@rjmholt
Copy link
Contributor

rjmholt commented Jun 21, 2018

Oh whoops, I left one of the braces in. Also we could try taking the colon out too:

"editor.wordSeparators": "`~!#%^&*()-=+[]\\|;'\",.<>/?"

(Also took the @ out for splatting)

@rkeithhill
Copy link
Contributor

rkeithhill commented Jun 23, 2018

That handles the $script:foo = 1 case but it still won't highlight the variable in this string "${script:foo}" when I have selected $script:foo in the assignment statement.

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

4 participants