Skip to content

Auto Format refuses to cuddle else to closing curly bracket #5243

@SEKCobra

Description

@SEKCobra

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

No matter what I set up in the formatting options, I am able to use condensed formatting, but can't get "else" to cuddle up to "}"

if($test){

} else{

}

It should be

if($test){

}else{

}

PowerShell Version

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

Name             : Visual Studio Code Host
Version          : 2025.2.0
InstanceId       : 77c13214-79c9-43cf-889e-a8de68e799d9
UI               : System.Management.Automation.Internal.Host.InternalHostUserInterface
CurrentCulture   : de-AT
CurrentUICulture : de-DE
PrivateData      : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy
DebuggerEnabled  : True
IsRunspacePushed : False
Runspace         : System.Management.Automation.Runspaces.LocalRunspace

Visual Studio Code Version

1.100.2
848b80aeb52026648a8ff9f7c45a9b0a80641e2e
x64

Extension Version

Steps to Reproduce

Disable all bracket whitespace options, put else on the same line as opening and closing brackets. Auto Format > Always adds a whitespace between the closing bracket and else.

Visuals

No response

Logs

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-Code FormattingIssue-BugA bug to squash.Pending: ExternalThis issue is not fixed here, it is fixed in a dependent repo such as PowerShell,PSScriptAnalyzer

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions