Skip to content

Preserve branch indentation after multiline conditions - #2271

Merged
Christoph Bergmeister (bergmeister) merged 2 commits into
copilot/ignore-onelineblock-correctionfrom
copilot/fix-code-for-review-comments
Oct 28, 2026
Merged

Christoph Bergmeister (bergmeister) merged 2 commits into
copilot/ignore-onelineblock-correctionfrom
copilot/fix-code-for-review-comments

Conversation

Copilot AI commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

PlaceCloseBrace could misindent a branch when the opening-brace line was part of a multiline condition. The formatter used that continuation line’s indentation instead of the closing brace’s indentation.

  • Correction: When a closing brace is already on its own line, use its indentation for the following branch.
  • Regression coverage: Add root-level and nested multiline-condition cases.
if (
    $true) {
    $true
} else {
    $false
}

The formatter now places else at the same indentation as }.

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

There are no active review issues for the branch-indentation formatting change.

No open issues 🎉

What changed in this PR

Fixes PlaceCloseBrace formatting so branches following multiline conditions align with the closing brace rather than the condition’s continuation line.

Changes:

  • Uses the closing brace’s indentation when it is on its own line, preserving the existing fallback otherwise.
  • Adds regression tests for root-level and nested multiline if conditions.
File Description
Tests/​Rules/​PlaceCloseBrace.tests.ps1 Adds root-level and nested branch-indentation regression tests.
Rules/​PlaceCloseBrace.cs Uses standalone closing-brace indentation for the following branch.

Review effort: Balanced

@bergmeister
Christoph Bergmeister (bergmeister) marked this pull request as ready for review October 28, 2026 11:56
@bergmeister
Christoph Bergmeister (bergmeister) merged commit 810f339 into copilot/ignore-onelineblock-correction Oct 28, 2026
9 checks passed
@bergmeister
Christoph Bergmeister (bergmeister) deleted the copilot/fix-code-for-review-comments branch October 28, 2026 12:09
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