PowerShell / PowerShell/vscode-powershell

Intellisense for "[PSCustomObject]" leaves an extra close square bracket causing a syntax error

Open
#5,003 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Area-Snippets Issue-Bug Up for Grabs
Dominant language
TypeScript
Stars
1.9k
Forks
547
PR merge metrics
No merged PRs in 30d

Description

Prerequisites
  • I have written a descriptive issue title.
  • I have searched all open and closed issues to ensure it has not already been reported.
  • I have read the troubleshooting guide.
  • I am sure this issue is with the extension itself and does not reproduce in a standalone PowerShell instance.
  • I have verified that I am using the latest version of Visual Studio Code and the PowerShell extension.
  • If this is a security issue, I have read the security issue reporting guidance.
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
$psversiontable ;host

Name                           Value
----                           -----
PSVersion                      7.4.2
PSEdition                      Core
GitCommitId                    7.4.2
OS                             Microsoft Windows 10.0.20348
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Name             : Visual Studio Code Host
Version          : 2024.2.2
InstanceId       : 795c2dfd-55fe-4258-b089-29937135df2b
UI               : System.Management.Automation.Internal.Host.InternalHos 
                   tUserInterface
CurrentCulture   : en-US
CurrentUICulture : en-US
PrivateData      : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy     
DebuggerEnabled  : True
IsRunspacePushed : False
Runspace         : System.Management.Automation.Runspaces.LocalRunspace
Visual Studio Code Version
code --version
1.90.0
89de5a8d4d6205e5b11647eb6a74844ca23d2573
x64
Extension Version
code --list-extensions --show-versions | select-string powershell

ms-vscode.powershell@2024.2.2
Steps to Reproduce

Type "[PSCustom" and then press the tab key

Visuals

Pressing TAB at this point:
image

Causes this extra square bracket at this point:
image

Logs

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue in Visual Studio Code by typing "[PSCustom" and pressing Tab, then trace the extension's IntelliSense completion handling. Done means completing the type name does not insert an extra closing square bracket and the resulting PowerShell remains syntactically valid.

Written by the indexing model from the issue text.

Assessment

Tech stack
powershell, typescript, vscode
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.