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 — Track formatter ranges through iterative corrections by Copilot · Pull Request #2264 · PowerShell/PSScriptAnalyzer

Conversation

Copilot AI commented Oct 27, 2026 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor

Invoke-Formatter -Range could silently drop later corrections when earlier edits moved them beyond the original range end. Shortening a selected line could also leave invalid range coordinates.

  • Range tracking: Update the range end after each applied correction, accounting for both line and column changes across iterations and rules.
  • Regression coverage: Cover expansion, contraction, multiline selections, and line insertion/removal while preserving adjacent unselected lines.
Invoke-Formatter -ScriptDefinition "if(`$a){'x'}`nif(`$b){'y'}" -Range @(2, 1, 2, 12)

Produces:

if($a){'x'}
if ($b) { 'y' }
  • Fixes Invoke-Formatter -Range silently drops corrections after earlier fixes shift text #2211

Sorry, something went wrong.

Uh oh!

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

All reactions
Initial plan
9d5d3b7
Copilot AI assigned Copilot and Christoph Bergmeister (bergmeister) Oct 27, 2026
Copilot started work on behalf of Christoph Bergmeister (bergmeister) October 27, 2026 22:30
View session
Copilot AI linked an issue Oct 27, 2026 that may be closed by this pull request
Invoke-Formatter -Range silently drops corrections after earlier fixes shift text #2211
Open
@bergmeister
Fix formatter range tracking through iterative edits
e021fce
Co-authored-by: bergmeister <[email protected]>
Copilot AI changed the title [WIP] Fix issue with Invoke-Formatter -Range dropping corrections Track formatter ranges through iterative corrections Oct 27, 2026
Copilot finished work on behalf of Christoph Bergmeister (bergmeister) October 27, 2026 22:38
Copilot AI requested a review from Christoph Bergmeister (bergmeister) October 27, 2026 22:38
@bergmeister
Christoph Bergmeister (bergmeister) requested a balanced review from Copilot October 28, 2026 07:17
Copilot started reviewing on behalf of Christoph Bergmeister (bergmeister) October 28, 2026 07:18
View session
Copilot AI reviewed Oct 28, 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

Empty replacements can cause range-endpoint mapping to throw after deleting selected lines, so zero-line replacements need explicit handling, including when no selected lines remain.

1 open issue
  • Medium severity Handle empty replacements without throwing on range endpoint mapping · New
What changed in this PR

This PR addresses #2211 by tracking formatter selection boundaries as corrections change the text, so later fixes remain within the intended range.

Changes:

  • Update the range endpoint after each correction, accounting for line and column changes.
  • Add regression coverage for expanding and shortening selections, inserting and removing lines, and preserving adjacent unselected lines.
File Description
Tests/​Engine/​InvokeFormatter.tests.ps1 Adds range-formatting regression cases.
Engine/​ScriptAnalyzer.cs Replaces per-pass line-count adjustment with per-correction endpoint tracking.

Review effort: Balanced

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread Engine/ScriptAnalyzer.cs Resolved

Uh oh!

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

Copilot started work on behalf of Christoph Bergmeister (bergmeister) October 28, 2026 07:24
View session
@bergmeister
Handle empty formatter replacements in ranges
e45a772
Co-authored-by: bergmeister <[email protected]>
Copilot finished work on behalf of Christoph Bergmeister (bergmeister) October 28, 2026 07:34
@bergmeister
Christoph Bergmeister (bergmeister) requested a balanced review from Copilot October 28, 2026 08:32
Copilot started reviewing on behalf of Christoph Bergmeister (bergmeister) October 28, 2026 08:32
View session
Copilot AI reviewed Oct 28, 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

Zero-line replacements mishandle selection endpoints, potentially causing negative-column exceptions or allowing subsequent formatting to modify originally unselected text.

2 open issues
  • Medium severity Prevent formatting from expanding exhausted selections · New
  • Medium severity Map deletion endpoint to surviving selected line end · New
1 resolved since last review
  • Medium severity Handle empty replacements without throwing on range endpoint mapping

Review effort: Balanced

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread Engine/ScriptAnalyzer.cs Resolved

Uh oh!

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

Comment thread Engine/ScriptAnalyzer.cs Resolved

Uh oh!

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

Copilot started work on behalf of Christoph Bergmeister (bergmeister) October 28, 2026 09:47
View session
@bergmeister
Preserve exhausted formatter selections
d039aa2
Co-authored-by: bergmeister <[email protected]>
Copilot finished work on behalf of Christoph Bergmeister (bergmeister) October 28, 2026 09:56
@bergmeister
Christoph Bergmeister (bergmeister) requested a balanced review from Copilot October 28, 2026 11:36
Copilot started reviewing on behalf of Christoph Bergmeister (bergmeister) October 28, 2026 11:36
View session
Copilot AI reviewed Oct 28, 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

No active review issues block the changes to keep formatter corrections within the intended selection.

No open issues 🎉

2 resolved since last review
  • Medium severity Map deletion endpoint to surviving selected line end
  • Medium severity Prevent formatting from expanding exhausted selections

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 28, 2026 11:40
@bergmeister
Christoph Bergmeister (bergmeister) requested a review from a team as a code owner October 28, 2026 11:40
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

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

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Invoke-Formatter -Range silently drops corrections after earlier fixes shift text

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.