Steps to reproduce
Format a one-line block with IgnoreOneLineBlock = $false:
Invoke-Formatter -ScriptDefinition "if (`$x) { BREAK }" -Settings @{
IncludeRules = @(
'PSPlaceOpenBrace'
'PSPlaceCloseBrace'
'PSUseConsistentIndentation'
'PSUseCorrectCasing'
)
Rules = @{
PSPlaceOpenBrace = @{
Enable = $true
OnSameLine = $true
NewLineAfter = $true
IgnoreOneLineBlock = $false
}
PSPlaceCloseBrace = @{
Enable = $true
NewLineAfter = $true
IgnoreOneLineBlock = $false
}
PSUseConsistentIndentation = @{ Enable = $true }
PSUseCorrectCasing = @{ Enable = $true }
}
}
Expected behavior
Expanding the block should not introduce trailing whitespace:
Actual behavior
The output contains a trailing space after break. The ␠ below marks that space:
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
Steps to reproduce
Format a one-line block with
IgnoreOneLineBlock = $false:Expected behavior
Expanding the block should not introduce trailing whitespace:
Actual behavior
The output contains a trailing space after
break. The␠below marks that space: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
PSAvoidTrailingWhitespaceavailable toInvoke-Formatterwhen explicitly configured. They do not preventPSPlaceOpenBraceandPSPlaceCloseBracefrom introducing trailing whitespace. Callers should not need a separate cleanup rule to remove whitespace created by the formatter itself.Environment data
Reproduced with:
mainat 4b0117c on PowerShell 7.6.4