vscode-powershell icon indicating copy to clipboard operation
vscode-powershell copied to clipboard

Reports Missing closing '}' on a if statement when not all on one line or the { not on the next line with powershell version 5

Open BenHuns opened this issue 1 month ago • 2 comments

Prerequisites

  • [x] I have written a descriptive issue title.
  • [x] I have searched all open and closed issues to ensure it has not already been reported.
  • [x] I have read the troubleshooting guide.
  • [x] I am sure this issue is with the extension itself and does not reproduce in a standalone PowerShell instance.
  • [x] I have verified that I am using the latest version of Visual Studio Code and the PowerShell extension.
  • [x] If this is a security issue, I have read the security issue reporting guidance.

Summary

When running the following simple script: `$ben = $true

if ($ben) { Write-Output "ben" } `

the extension throws this error:

Missing closing '}' in statement block or type definition. + CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException + FullyQualifiedErrorId : MissingEndCurlyBrace

if the script looks like this: `$ben = $true

if ($ben) { Write-Output "ben" }`

or this: `$ben = $true

if ($ben) { Write-Output "ben" } `

it works. Or if I switch to version 7 of powershell.

PowerShell Version

Name                           Value                                                                                   
----                           -----                                                                                   
PSVersion                      5.1.26100.6584                                                                          
PSEdition                      Desktop                                                                                 
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                                 
BuildVersion                   10.0.26100.6584                                                                         
CLRVersion                     4.0.30319.42000                                                                         
WSManStackVersion              3.0                                                                                     
PSRemotingProtocolVersion      2.3                                                                                     
SerializationVersion           1.1.0.1

Visual Studio Code Version

1.105.1
x64

Extension Version

[email protected]

Steps to Reproduce

see description

Visuals

No response

Logs

No logs

Image

Log level set to trace:

Image

found these ms-vscode.powershell.zip

BenHuns avatar Oct 17 '25 16:10 BenHuns