GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Preserve relative indentation in commented-out code by Copilot · Pull Request #2231 · PowerShell/PSScriptAnalyzer

Conversation

Copilot AI commented Oct 22, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

PSUseConsistentIndentation flattened commented-out code by aligning each comment marker independently, erasing indentation that represented nested structure. Comment runs should retain their relative indentation, while still allowing the run to align with its surrounding code.

  • Comment-run indentation: Preserve column offsets across adjacent standalone comment lines when applying indentation corrections. Inline comments are not grouped into a run.
  • Regression coverage: Cover space and tab indentation, shifting a run as a unit, and code following the run.

For example, the nested comment remains nested after formatting:

if ($a) {
    # if ($b) {
        # doThing
    # }
    Write-Output 'after'
}
  • Fixes PSUseConsistentIndentation flattens the indentation of commented-out code #2217

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Initial plan
6f2826a
Copilot AI assigned Copilot and Christoph Bergmeister (bergmeister) Oct 22, 2026
Copilot started work on behalf of Christoph Bergmeister (bergmeister) October 22, 2026 22:00
View session
Copilot AI linked an issue Oct 22, 2026 that may be closed by this pull request
PSUseConsistentIndentation flattens the indentation of commented-out code #2217
Open
Copilot AI and others added 2 commits October 22, 2026 22:04
@bergmeister
Preserve comment-run indentation
7092b4c
Co-authored-by: bergmeister <[email protected]>
@bergmeister
Refine comment-run handling
9941989
Co-authored-by: bergmeister <[email protected]>
Copilot AI changed the title [WIP] Fix PSUseConsistentIndentation flattening indented comments Preserve relative indentation in commented-out code Oct 22, 2026
Copilot finished work on behalf of Christoph Bergmeister (bergmeister) October 22, 2026 22:10
Copilot AI requested a review from Christoph Bergmeister (bergmeister) October 22, 2026 22:10
@bergmeister
Christoph Bergmeister (bergmeister) requested a balanced review from Copilot October 22, 2026 23:10
Copilot started reviewing on behalf of Christoph Bergmeister (bergmeister) October 22, 2026 23:11
View session
Copilot AI reviewed Oct 22, 2026
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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.

🟡 Changes recommended

Some comment runs still lose relative indentation, and repeated backward scans introduce quadratic processing.

3 open issues
  • Medium severity Avoid quadratic rescanning of comment runs · New
  • Medium severity Handle comment runs after backtick continuations · New
  • Medium severity Preserve relative indentation across comment runs · New
What changed in this PR

This PR addresses #2217 by updating PSUseConsistentIndentation to preserve relative indentation in adjacent standalone comments instead of flattening commented-out code.

Changes:

  • Calculates comment-run offsets and applies them to indentation corrections.
  • Adds space- and tab-based regression tests for preserving runs, shifting runs together, and retaining following code.
File Description
Tests/​Rules/​UseConsistentIndentation.tests.ps1 Adds comment-run formatting regression tests.
Rules/​UseConsistentIndentation.cs Incorporates relative comment offsets into indentation corrections.

Review effort: Balanced

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Rules/UseConsistentIndentation.cs Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Rules/UseConsistentIndentation.cs Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Rules/UseConsistentIndentation.cs Resolved

Uh oh!

There was an error while loading. Please reload this page.

Copilot started work on behalf of Christoph Bergmeister (bergmeister) October 26, 2026 10:04
View session
@bergmeister
Christoph Bergmeister (bergmeister) added this pull request to stack #2237 October 26, 2026 10:05
Copilot AI mentioned this pull request Oct 26, 2026
Preserve relative indentation in comment runs #2236
Merged
Copilot finished work on behalf of Christoph Bergmeister (bergmeister) October 26, 2026 10:05
Copilot AI mentioned this pull request Oct 26, 2026
Preserve relative indentation in commented-out code #2238
Merged
Copilot started work on behalf of Christoph Bergmeister (bergmeister) October 26, 2026 10:07
View session
Copilot finished work on behalf of Christoph Bergmeister (bergmeister) October 26, 2026 10:08
@bergmeister
Christoph Bergmeister (bergmeister) removed this pull request from stack #2237 October 26, 2026 10:42
@bergmeister
Christoph Bergmeister (bergmeister) added this pull request to stack #2239 October 26, 2026 10:58
@bergmeister
Preserve relative indentation in comment runs (#2236)
0c2d630
* Initial plan

* Preserve indentation across comment runs

Co-authored-by: bergmeister <[email protected]>

---------

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: bergmeister <[email protected]>
@bergmeister
Christoph Bergmeister (bergmeister) removed this pull request from stack #2239 October 26, 2026 11:41
@bergmeister
Christoph Bergmeister (bergmeister) added this pull request to stack #2240 October 26, 2026 11:47
@bergmeister
Christoph Bergmeister (bergmeister) removed this pull request from stack #2240 October 26, 2026 20:40
@bergmeister
Preserve relative indentation in commented-out code (#2238)
227ab25
* Initial plan

* Fix comment runs after line continuations

Co-authored-by: bergmeister <[email protected]>

* Fix continuation indent after comment runs

Co-authored-by: bergmeister <[email protected]>

* Include line continuations in comment scan

Co-authored-by: bergmeister <[email protected]>

* Apply last suggestion 'Prevent double-counting indentation in comment runs' #2238 (comment)

* Fix Pester discovery by removing extra BOM

Co-authored-by: bergmeister <[email protected]>

---------

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: bergmeister <[email protected]>
Co-authored-by: Christoph Bergmeister <[email protected]>
@bergmeister
Christoph Bergmeister (bergmeister) requested a balanced review from Copilot October 26, 2026 20:44
Copilot started reviewing on behalf of Christoph Bergmeister (bergmeister) October 26, 2026 20:45
View session
Copilot AI reviewed Oct 26, 2026
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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.

🟡 Changes recommended

Inline block comments and comment runs after pipes still have unresolved indentation errors.

2 open issues
  • Medium severity Preserve comment-run indentation when pipeline indentation is disabled · New
  • Medium severity Exclude inline executable comments from indentation correction · New
3 resolved since last review
  • Medium severity Preserve relative indentation across comment runs
  • Medium severity Handle comment runs after backtick continuations
  • Medium severity Avoid quadratic rescanning of comment runs

Review effort: Balanced

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Rules/UseConsistentIndentation.cs Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Rules/UseConsistentIndentation.cs Resolved

Uh oh!

There was an error while loading. Please reload this page.

@bergmeister
Christoph Bergmeister (bergmeister) requested a balanced review from Copilot October 27, 2026 14:11
Copilot started reviewing on behalf of Christoph Bergmeister (bergmeister) October 27, 2026 14:12
View session
Copilot AI reviewed Oct 27, 2026
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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.

🔵 Needs a closer look

Confidence in all multiline comment-group boundaries remains limited, and the regression tests have not been run.

No open issues 🎉

Review effort: Balanced

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bergmeister
Christoph Bergmeister (bergmeister) removed this pull request from stack #2254 October 27, 2026 14:31
@bergmeister
[WIP] Fix issue with preserving relative indentation in comments (#2253)
067cbda
* Initial plan

* Fix multiline comment group detection

Co-authored-by: bergmeister <[email protected]>

---------

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: bergmeister <[email protected]>
@bergmeister
Christoph Bergmeister (bergmeister) requested a balanced review from Copilot October 27, 2026 15:03
Copilot started reviewing on behalf of Christoph Bergmeister (bergmeister) October 27, 2026 15:04
View session
Copilot AI reviewed Oct 27, 2026
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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.

🔵 Needs a closer look

Stateful interactions between comment grouping, continuations, and pipelines warrant human validation of formatter correctness and repeated-formatting stability.

No open issues 🎉

Review effort: Balanced

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bergmeister
Christoph Bergmeister (bergmeister) marked this pull request as ready for review October 27, 2026 15:17
@bergmeister Christoph Bergmeister (bergmeister) added the Area - Formatter label Oct 27, 2026
@bergmeister
Christoph Bergmeister (bergmeister) added this pull request to stack #2256 October 27, 2026 17:11
@bergmeister
Christoph Bergmeister (bergmeister) removed this pull request from stack #2256 October 27, 2026 17:25
@bergmeister
Exclude trailing inline comments from comment runs (#2255)
91e54c2
Add a regression test for standalone comments following trailing inline comments.\n\nCo-authored-by: Copilot <[email protected]>

Co-authored-by: bergmeister <[email protected]>
@bergmeister
Christoph Bergmeister (bergmeister) requested a balanced review from Copilot October 27, 2026 17:29
Copilot started reviewing on behalf of Christoph Bergmeister (bergmeister) October 27, 2026 17:30
View session
Copilot AI reviewed Oct 27, 2026
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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.

🔵 Needs a closer look

Inline comments after line-leading pipes can still join standalone comment runs and incorrectly shift pipeline indentation.

No open issues 🎉

1 previously missed issue

In code that hasn't changed since last review

Medium severity Exclude trailing comments from pipeline indentation offset calculation

Rules/​UseConsistentIndentation.cs:373

With PipelineIndentation = 'NoIndentation', a line-leading pipe's trailing comment reaches this scan and is incorrectly grouped with following standalone comments. For a function containing a four-space-indented, backtick-continued foo, then | # trailing, # standalone, and bar, formatting moves the pipe from column 5 to column 11. Exclude comments with code before them as well as code after them from run-offset calculation.

Review effort: Balanced

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bergmeister
Add tests for handling comment run boundaries and indentation resets
4069f2a
@bergmeister

Christoph Bergmeister (bergmeister) commented Oct 27, 2026

Copy link
Copy Markdown
Collaborator

🔵 Needs a closer look

Inline comments after line-leading pipes can still join standalone comment runs and incorrectly shift pipeline indentation.

No open issues 🎉

1 previously missed issue
In code that hasn't changed since last review

Medium severity Exclude trailing comments from pipeline indentation offset calculation
Rules/​UseConsistentIndentation.cs:373

With PipelineIndentation = 'NoIndentation', a line-leading pipe's trailing comment reaches this scan and is incorrectly grouped with following standalone comments. For a function containing a four-space-indented, backtick-continued foo, then | # trailing, # standalone, and bar, formatting moves the pipe from column 5 to column 11. Exclude comments with code before them as well as code after them from run-offset calculation.

Review effort: Balanced

Copilot fix and add regression test. create new pr instead of pushing to this branch

Copilot reacted with eyes emoji
All reactions
  • 👀 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bergmeister
Christoph Bergmeister (bergmeister) added this pull request to stack #2258 October 27, 2026 17:51
Copilot AI mentioned this pull request Oct 27, 2026
Preserve relative indentation in commented-out code #2257
Merged

Copilot AI commented Oct 27, 2026

Copy link
Copy Markdown
Contributor Author

Christoph Bergmeister (@bergmeister) I've opened a new pull request, #2257, to work on those changes. Once the pull request is ready, I'll request review from you.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bergmeister
Christoph Bergmeister (bergmeister) removed this pull request from stack #2258 October 27, 2026 18:15
@bergmeister
Preserve relative indentation in commented-out code (#2257)
3f33813
* Initial plan

* Exclude trailing pipe comments from comment runs

Co-authored-by: bergmeister <[email protected]>

---------

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: bergmeister <[email protected]>
@bergmeister
Christoph Bergmeister (bergmeister) requested a balanced review from Copilot October 27, 2026 18:16
Copilot started reviewing on behalf of Christoph Bergmeister (bergmeister) October 27, 2026 18:16
View session
Copilot AI reviewed Oct 27, 2026
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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

The implementation and regression coverage address the reported indentation loss, with no unresolved blocking findings.

No open issues 🎉

Review effort: Balanced

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bergmeister
Christoph Bergmeister (bergmeister) added this pull request to stack #2261 October 27, 2026 18:30
Copilot AI mentioned this pull request Oct 27, 2026
Add pipeline comment indentation regression tests #2260
Merged
5 of 6 tasks
@bergmeister
test: cover comment indentation in pipelines (#2260)
27e6f68
Co-authored-by: bergmeister <[email protected]>
Co-authored-by: Copilot <[email protected]>
Copilot AI reviewed Oct 27, 2026
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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.

🔵 Needs a closer look

Recursive comment scanning interacts with continuation and pipeline indentation, warranting final human validation despite the extensive regression coverage.

No open issues 🎉

Review effort: Balanced

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

Copilot code review Copilot
Copilot review effort
Applies to this pull request for everyone.Learn more about Copilot code review.
Copilot left review comments
@bergmeister Christoph Bergmeister (bergmeister) Awaiting requested review from bergmeister bergmeister is a code owner
@michaeltlombardi Mikey Lombardi (He/Him) (michaeltlombardi) Awaiting requested review from michaeltlombardi michaeltlombardi is a code owner

At least 1 approving review is required to merge this pull request.

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@bergmeister Christoph Bergmeister (bergmeister)

Copilot code review Copilot

Labels

Area - Formatter

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

PSUseConsistentIndentation flattens the indentation of commented-out code

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@bergmeister
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.