Powershell multiple ) get removed when I type one nested
Issue Type: Bug
I'm not sure if this is a bug or not. When I put am trying to insert things with ) inside of another set of (), any ) characters to the right get removed, and I'm left with one. It is really annoying.
Example: if ((1=1) | (2=2)) In this example, if I was adding the (2=2) after creating the original (1=1), the format would become: ((1=1) | (2=2)
Extension version: 1.6.0 VS Code version: Code 1.22.2 (3aeede733d9a3098f7b4bdc1f66b63b0f48c1ef9, 2018-04-12T16:38:45.278Z) OS version: Windows_NT x64 10.0.16299
System Info
| Item | Value |
|---|---|
| CPUs | Intel(R) Core(TM) i7-6600U CPU @ 2.60GHz (4 x 2808) |
| Memory (System) | 11.87GB (3.37GB free) |
| Process Argv | C:\Program Files\Microsoft VS Code\Code.exe |
| Screen Reader | no |
| VM | 0% |
Hi @metalmensch thanks for the report! I'm not quite sure I follow you on the example. Are you saying that you're doing:
if((1 -eq 1))
and are trying to add (paste?) | (2 -eq 2 ) between the last two ) and the last one goes away?
Effectively that. Yes. The )) becomes ) when the left hand one is inserted.
On Fri, Apr 20, 2018, 16:57 Tyler James Leonhardt [email protected] wrote:
Hi @metalmensch https://github.com/metalmensch thanks for the report! I'm not quite sure I follow you on the example. Are you saying that you're doing:
if((1 -eq 1))
and are trying to add (paste?) | (2 -eq 2 ) between the last two ) and the last one goes away?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/PowerShell/vscode-powershell/issues/1279#issuecomment-383250270, or mute the thread https://github.com/notifications/unsubscribe-auth/AagPnZMwyKDgAYh6yTQ34pFYfHhn3HmMks5tqnXRgaJpZM4TdyU3 .
hmm I can't seem to repro what you're experiencing. Can you give me a few more examples and I'll keep trying?
@tylerl0706, not the person who opened this but
- Open a new file.
- Type
(which should auto complete()with your cursor in the middle. - Type
)and you'll notice it still only says()with your cursor outside instead of())
It appears to be an issue with VS Code in general though and not just the PowerShell extension as it does the same thing in say C#. Typically the completion of () any time you type an opening bracket makes this an non-issue but every now and then I notice it. A contrived example but an example all the same:
You have this in code:
if ($MyValue) {
#DO SOMETHING
}
and you copy -not($SomeVariable) from somewhere else to replace $MyVariable but miss the closing ) giving you:
if (-not($SomeVariable) {
#DO SOMETHING
}
with your cursor between the e and the ). If you type ) to close the -not() it doesn't type anything. VS Code eats the bracket. You have to hit ) twice in order to get:
if (-not($SomeVariable)) {
#DO SOMETHING
}
If this is what the original bug was about then yes, @omniomi, you are totally right - that's a VSCode bug and quite a difficult one to fix, I'm sure.
There might actually be such an issue opened already.
That is indeed the thing. Not a powershell specific thing after all. I'll check over in the general section. Thank you.
On Tue, May 1, 2018, 19:29 Tyler James Leonhardt [email protected] wrote:
If this is what the original bug was about then yes, @omniomi https://github.com/omniomi, you are totally right - that's a VSCode bug and quite a difficult one to fix, I'm sure.
There might actually be such an issue opened already.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/PowerShell/vscode-powershell/issues/1279#issuecomment-385847043, or mute the thread https://github.com/notifications/unsubscribe-auth/AagPnZlh-xfBYJykmfL6YnKRCO9VVqAuks5tuRoVgaJpZM4TdyU3 .
This is something a lot of modern editors do that automatically close brackets for you. The idea behind it is that it's a lot easier on the wrist to type the close bracket than it is to stretch all the way to the arrow keys.
It doesn't appear that there is a way to turn off this behavior specifically, but if you set edit.autoClosingBrackets to false in your settings the behavior disappears.
Related issue: Microsoft/vscode#34606
Thanks @SeeminglyScience! I'm going to close this now as external but I encourage you to 👍 that issue so the VSCode team can prioritize.
Let us know if you have any concerns about the extension - we're happy to help 🙂