Repository navigation
Preserve Invoke-Formatter idempotence for --% arguments - #2265
Open
Christoph Bergmeister (bergmeister) with Copilot wants to merge 2 commits into
Open
Christoph Bergmeister (bergmeister) with Copilot wants to merge 2 commits into
Christoph Bergmeister (bergmeister) with Copilot wants to merge 2 commits into
Conversation
Co-authored-by: bergmeister <9250262+bergmeister@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix Invoke-Formatter idempotency issue with --% verbatim arguments
Preserve Invoke-Formatter idempotence for Oct 27, 2026
--% arguments
Contributor
There was a problem hiding this comment.
🟢 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
Christoph Bergmeister (bergmeister)
marked this pull request as ready for review
October 28, 2026 07:23
Christoph Bergmeister (bergmeister)
requested a review
from a team
as a code owner
October 28, 2026 07:23
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Repeated formatting of
cmd --% raw | text & stuffinserts another space before|on every pass. The parser includes trailing whitespace in the verbatim argument token, causingPSUseConsistentWhitespaceto misidentify a missing separator.--%verbatim argument. Continue formatting whitespace after that pipe and around other pipes.--%verbatim arguments #2209