You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
PSPlaceOpenBrace and PSPlaceCloseBrace leave trailing whitespace when expanding one-line blocks #2210
Expanding the block should not introduce trailing whitespace:
if ($x) {
break
}
Actual behavior
The output contains a trailing space after break. The ␠ below marks that space:
if ($x) {
break␠
}
The brace corrections replace only the brace tokens. The spaces that separated the one-line content from the braces survive as trailing whitespace after the block is expanded.
#1992 and merged #1993 are related, but not duplicates. They make PSAvoidTrailingWhitespace available to Invoke-Formatter when explicitly configured. They do not prevent PSPlaceOpenBrace and PSPlaceCloseBrace from introducing trailing whitespace. Callers should not need a separate cleanup rule to remove whitespace created by the formatter itself.
Environment data
Reproduced with:
PSScriptAnalyzer 1.25.0 on PowerShell 7.5.2
PSScriptAnalyzer built from main at 4b0117c on PowerShell 7.6.4
changed the title [-]PSPlaceOpenBrace and PSPlaceCloseBrace leave trailing whitespace when expanding one-line blocks[/-][+]`PSPlaceOpenBrace` and `PSPlaceCloseBrace` leave trailing whitespace when expanding one-line blocks[/+]on Aug 24, 2026
Activity
[-]PSPlaceOpenBrace and PSPlaceCloseBrace leave trailing whitespace when expanding one-line blocks[/-][+]`PSPlaceOpenBrace` and `PSPlaceCloseBrace` leave trailing whitespace when expanding one-line blocks[/+]