Skip to content

Prevent repeated indentation of multiline comment runs - #2251

Merged
Christoph Bergmeister (bergmeister) merged 2 commits into
copilot/fix-psuseconsistentindentation-issuefrom
copilot/fix-comments-from-review
Oct 27, 2026
Merged

Christoph Bergmeister (bergmeister) merged 2 commits into
copilot/fix-psuseconsistentindentation-issuefrom
copilot/fix-comments-from-review

Conversation

Copilot AI commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

A secondary block comment could incorrectly set the indentation anchor for a standalone comment run, causing indentation to drift across formatter passes.

  • Comment-run anchoring: Measure the minimum indentation from the first comment in each standalone group, while still traversing the remaining comment tokens.
  • Regression coverage: Check that formatting this case preserves its indentation on repeated passes:
if ($a) {
    <# first
#> <# second #>
        # nested
}

Co-authored-by: bergmeister <9250262+bergmeister@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix code for all comments in review thread and add regression test Prevent repeated indentation of multiline comment runs Oct 27, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 are reported for the change addressing indentation drift in standalone comment groups.

No open issues 🎉

What changed in this PR

This PR prevents indentation drift when repeatedly formatting standalone comment runs containing multiline block comments.

Changes:

  • Calculate minimum indentation using only the first comment in each standalone group, while continuing to traverse all comment tokens.
  • Add a regression test that verifies indentation remains unchanged across two formatter passes.
File Description
Tests/​Rules/​UseConsistentIndentation.tests.ps1 Adds repeated-formatting coverage for adjacent multiline block comments and a nested comment.
Rules/​UseConsistentIndentation.cs Prevents secondary comments in a group from changing the indentation anchor.

Review effort: Balanced

@bergmeister
Christoph Bergmeister (bergmeister) marked this pull request as ready for review October 27, 2026 13:42
@bergmeister
Christoph Bergmeister (bergmeister) merged commit 984815c into copilot/fix-psuseconsistentindentation-issue Oct 27, 2026
8 of 11 checks passed
@bergmeister
Christoph Bergmeister (bergmeister) deleted the copilot/fix-comments-from-review branch October 27, 2026 13:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants