GeezerVison is showing github.com — Preserve Invoke-Formatter idempotence for `--%` arguments by Copilot · Pull Request #2265 · PowerShell/PSScriptAnalyzer
Conversation
Copilot
AI
commented
Oct 27, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Repeated formatting of cmd --% raw | text & stuff inserts another space before | on every pass. The parser includes trailing whitespace in the verbatim argument token, causing PSUseConsistentWhitespace to misidentify a missing separator.
- Boundary handling: Skip pre-pipe spacing corrections immediately after a
--% verbatim argument. Continue formatting whitespace after that pipe and around other pipes.
- Regression coverage: Check repeated formatting with zero, multiple, and tab spacing, plus empty verbatim arguments and redundant-whitespace mode.
# Remains unchanged across formatting passes:
cmd --% raw | text & stuff
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Copilot
AI
changed the title
[WIP] Fix Invoke-Formatter idempotency issue with --% verbatim arguments
Preserve Invoke-Formatter idempotence for --% arguments
Oct 27, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟢 Approval recommended
No active review issues remain for the fix preserving verbatim-argument whitespace before pipes.
No open issues 🎉
What changed in this PR
Addresses #2209 by preventing Invoke-Formatter from repeatedly inserting spaces before pipes following --% verbatim arguments.
Changes:
- Skip pre-pipe whitespace corrections after verbatim arguments while preserving formatting after the pipe and around other pipes.
- Add repeated-formatting regression tests for zero, multiple, and tab spacing, plus empty verbatim arguments.
- Verify redundant-whitespace mode preserves verbatim whitespace while correcting spacing after the pipe.
| File |
Description |
| Tests/Rules/UseConsistentWhitespace.tests.ps1 |
Tests surrounding pipe formatting and redundant-whitespace handling. |
| Tests/Engine/InvokeFormatter.tests.ps1 |
Tests verbatim argument preservation across repeated formatting passes. |
| Rules/UseConsistentWhitespace.cs |
Skips pre-pipe spacing corrections immediately after verbatim arguments. |
Review effort: Balanced
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Reviewers
At least 1 approving review is required to merge this pull request.
Uh oh!
There was an error while loading. Please reload this page.
Milestone
No milestone
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.