-
Notifications
You must be signed in to change notification settings - Fork 490
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
Intellisense for "[PSCustomObject]" leaves an extra close square bracket causing a syntax error #5003
Comments
Thanks for the report! This is a snippet and will need to be addressed there, should be fairly simple. In the meantime, if you choose the option to sort snippet suggestions to bottom, the normal intellisense will apply. |
Relevant snippet to fix vscode-powershell/snippets/PowerShell.json Lines 529 to 540 in ef038c8
|
As far as i can see, it seems the external close square bracket isnt really a bug. I think you have an extension that adds the right closing bracket but the cursor position doesnt go beyond it when you tab. Try the following:
Now repeat but before you press the tab for completion, move the character one position to the right so now it is positioned on the closing bracket. If you press the tab now, it will be expanded correctly without "extra" closing bracket. You can also test it without using brackets, but you just can use ps by itself, but if you type psc and then tab, it will expand correctly and again not show "extra" closing bracket. Hope this made sense. |
Yes, that approach makes sense as a workaround, although it's unique compared to Intellisense's behavior in other contexts. Typically, when the suggestion box appears, pressing TAB fills in the command as expected. However, with [PSCustomObject], Intellisense's performance is inconsistent. I'll make a mental note of how to manage it in these situations. Thank you for the information; it was useful, even if not quite what I was looking for. |
The intention was not necessarily to provide a workaround, but rather to show why its not really a bug. What you're seeing, and i do as well, is actually the expected behavior in my eyes. You can replace the opening bracket with say @@ and typing in between them pscustomobject and then press tab for expansion and you will see that only the inside was expanded. as for consistency, i think its actually behaves the same in other places where the prefix has at least 2 options, one with square brackets and one without. An example is in lines 500-512 using [SuppressMessageAttribute] Can always try to run VSCode without anything else other than the PowerShell extension and verify that nothing adds a closing brackets and test again and you will not see that closing bracket as the closing one will not appear immediately after you typed the opening one. |
Prerequisites
Summary
Using Intellisesnse while typing-out [PSCustomObject], before I type the closing square brackets, an extra square bracket is appended, causing a syntax error.
PowerShell Version
Visual Studio Code Version
Extension Version
Steps to Reproduce
Type "[PSCustom" and then press the tab key
Visuals
Pressing TAB at this point:
Causes this extra square bracket at this point:
Logs
No response
The text was updated successfully, but these errors were encountered: