Steps to reproduce
Format only the second line, with the range covering the complete statement:
Invoke-Formatter -ScriptDefinition "if(`$a){'x'}`nif(`$b){'y'}" -Range @(2, 1, 2, 12)
Expected behavior
Every formatting correction within the selected statement should be applied:
if($a){'x'}
if ($b) { 'y' }
Actual behavior
The space before the final } is missing:
if($a){'x'}
if ($b) { 'y'}
The formatter applies fixes iteratively. Earlier corrections make the selected line longer, but later violations are still filtered against the original fixed range coordinates. Once a correction shifts beyond the original range end, it is silently dropped even though it belongs to the statement selected by the caller.
Expected resolution
Track the range through applied edits, or filter corrections once against their original extents, so that a range covering a complete statement formats that statement completely.
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 only the second line, with the range covering the complete statement:
Expected behavior
Every formatting correction within the selected statement should be applied:
Actual behavior
The space before the final
}is missing:The formatter applies fixes iteratively. Earlier corrections make the selected line longer, but later violations are still filtered against the original fixed range coordinates. Once a correction shifts beyond the original range end, it is silently dropped even though it belongs to the statement selected by the caller.
Expected resolution
Track the range through applied edits, or filter corrections once against their original extents, so that a range covering a complete statement formats that statement completely.
Environment data
Reproduced with:
mainat 4b0117c on PowerShell 7.6.4