Skip to content

Preserve relative indentation in commented-out code - #2238

Merged
Christoph Bergmeister (bergmeister) merged 7 commits into
copilot/fix-psuseconsistentindentation-issuefrom
copilot/fix-code-review-comment-2231
Oct 26, 2026
Merged

Christoph Bergmeister (bergmeister) merged 7 commits into
copilot/fix-psuseconsistentindentation-issuefrom
copilot/fix-code-review-comment-2231

Conversation

Copilot AI commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Formatting could flatten indentation within commented-out code blocks. The formatter now preserves relative indentation when aligning comment runs.

  • Comment-run indentation: Keep the first comment aligned with the surrounding code while retaining each subsequent comment’s offset, for both spaces and tabs.
  • Suggested corrections: Apply the calculated indentation to formatter corrections as well as diagnostics.

For example, nested indentation remains intact when the block is shifted:

    # if ($b) {
        # doThing
    # }

Copilot AI changed the title [WIP] Fix code based on review comment #2231 Preserve relative indentation in commented-out code Oct 26, 2026
@bergmeister
Christoph Bergmeister (bergmeister) marked this pull request as ready for review October 26, 2026 10:41

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.

Copilot wasn't able to review any files in this pull request. Check if the Files changed in this pull request are included in default exclusions.

Co-authored-by: bergmeister <9250262+bergmeister@users.noreply.github.com>

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.

🟡 Changes recommended

Continuation indentation is still lost on the command argument following multiple comments, conflicting with the new regression assertion.

1 open issue

Review effort: Balanced

Comment thread Rules/UseConsistentIndentation.cs
Co-authored-by: bergmeister <9250262+bergmeister@users.noreply.github.com>
@bergmeister

Copy link
Copy Markdown
Collaborator

Copilot resolve the merge conflicts in this pull request

…tation-issue' into copilot/fix-code-review-comment-2231

# Conflicts:
#	Rules/UseConsistentIndentation.cs
#	Tests/Rules/UseConsistentIndentation.tests.ps1

Co-authored-by: bergmeister <9250262+bergmeister@users.noreply.github.com>

Copilot AI commented Oct 26, 2026

Copy link
Copy Markdown
Contributor Author

Copilot resolve the merge conflicts in this pull request

Resolved the merge conflicts and merged copilot/fix-psuseconsistentindentation-issue into this branch. The merge commit is fa021dd; all 97 focused indentation tests pass.

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.

🟡 Changes recommended

Inconsistent forward and backward scanning can still lose relative indentation in comment runs separated by explicit line continuations.

2 open issues

Review effort: Balanced

Comment thread Rules/UseConsistentIndentation.cs
Co-authored-by: bergmeister <9250262+bergmeister@users.noreply.github.com>

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.

🟡 Changes recommended

A continuation inside a comment run can still cause indentation to grow on repeated formatting passes.

1 open issue
2 resolved since last review

Review effort: Balanced

Comment thread Rules/UseConsistentIndentation.cs Outdated
Co-authored-by: bergmeister <9250262+bergmeister@users.noreply.github.com>

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

The continuation handling is consistent, focused regression tests cover the changed behavior, and no blocking issues remain.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@bergmeister
Christoph Bergmeister (bergmeister) marked this pull request as ready for review October 26, 2026 20:40
@bergmeister
Christoph Bergmeister (bergmeister) merged commit 227ab25 into copilot/fix-psuseconsistentindentation-issue Oct 26, 2026
8 checks passed
@bergmeister
Christoph Bergmeister (bergmeister) deleted the copilot/fix-code-review-comment-2231 branch October 26, 2026 20:44
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