Title: `Invoke-Formatter -Range` silently drops corrections after earlier fixes shift text · Issue #2211 · PowerShell/PSScriptAnalyzer · GitHub
Open Graph Title: `Invoke-Formatter -Range` silently drops corrections after earlier fixes shift text · Issue #2211 · PowerShell/PSScriptAnalyzer
X Title: `Invoke-Formatter -Range` silently drops corrections after earlier fixes shift text · Issue #2211 · PowerShell/PSScriptAnalyzer
Description: Steps to reproduce Format only the second line, with the range covering the complete statement: Invoke-Formatter -ScriptDefinition "if(`$a){'x'}`nif(`$b){'y'}" -Range @(2, 1, 2, 12) Expected behavior Every formatting correction within th...
Open Graph Description: Steps to reproduce Format only the second line, with the range covering the complete statement: Invoke-Formatter -ScriptDefinition "if(`$a){'x'}`nif(`$b){'y'}" -Range @(2, 1, 2, 12) Expected behavi...
X Description: Steps to reproduce Format only the second line, with the range covering the complete statement: Invoke-Formatter -ScriptDefinition "if(`$a){'x'}`nif(`$b){'y'}" -Range @(2,...
Opengraph URL: https://github.com/PowerShell/PSScriptAnalyzer/issues/2211
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`Invoke-Formatter -Range` silently drops corrections after earlier fixes shift text","articleBody":"Steps to reproduce\n------------------\n\nFormat only the second line, with the range covering the complete statement:\n\n```powershell\nInvoke-Formatter -ScriptDefinition \"if(`$a){'x'}`nif(`$b){'y'}\" -Range @(2, 1, 2, 12)\n```\n\nExpected behavior\n-----------------\n\nEvery formatting correction within the selected statement should be applied:\n\n```powershell\nif($a){'x'}\nif ($b) { 'y' }\n```\n\nActual behavior\n---------------\n\nThe space before the final `}` is missing:\n\n```powershell\nif($a){'x'}\nif ($b) { 'y'}\n```\n\nThe formatter applies fixes iteratively. Earlier corrections make the selected line longer, but later violations are still filtered against the original fixed range coordinates. Once a correction shifts beyond the original range end, it is silently dropped even though it belongs to the statement selected by the caller.\n\nExpected resolution\n-------------------\n\nTrack the range through applied edits, or filter corrections once against their original extents, so that a range covering a complete statement formats that statement completely.\n\nEnvironment data\n----------------\n\nReproduced with:\n\n- PSScriptAnalyzer 1.25.0 on PowerShell 7.5.2\n- PSScriptAnalyzer built from `main` at PowerShell/PSScriptAnalyzer@4b0117ca7d2887711c9699f467ba7171f8859156 on PowerShell 7.6.4\n","author":{"url":"https://github.com/kjanat","@type":"Person","name":"kjanat"},"datePublished":"2026-08-24T15:55:09Z","url":"https://github.com/PowerShell/PSScriptAnalyzer/issues/2211"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:bea5a3a7-44e4-4e85-2a8b-cb8f8e990843 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B1AE:1E6ACE:323267:42AE43:6AFCE5ED |
| html-safe-nonce | 7cd7a2e13373cf574473d126801af13fe54f3f725defdf3bc3f8722c22172662 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMUFFOjFFNkFDRTozMjMyNjc6NDJBRTQzOjZBRkNFNUVEIiwidmlzaXRvcl9pZCI6Ijg1OTA2MDk1OTk0NDUxMzI3ODEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 81525aff050ae91a98f1ba164c214ddd4e48ff7a628a14e814a0897b0e5f6948 |
| hovercard-subject-tag | issue:5236781441 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/PowerShell/PSScriptAnalyzer/2211/issue_layout |
| twitter:image | https://opengraph.githubassets.com/9abd8b0beec0b20064f836818d873a94b610dc7b1954d6f7342ba5a9cf585e86/PowerShell/PSScriptAnalyzer/issues/2211 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/9abd8b0beec0b20064f836818d873a94b610dc7b1954d6f7342ba5a9cf585e86/PowerShell/PSScriptAnalyzer/issues/2211 |
| og:image:alt | Steps to reproduce Format only the second line, with the range covering the complete statement: Invoke-Formatter -ScriptDefinition "if(`$a){'x'}`nif(`$b){'y'}" -Range @(2, 1, 2, 12) Expected behavi... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | kjanat |
| hostname | github.com |
| expected-hostname | github.com |
| None | 99aede4c5f55ec5cf06666a8c9e03ebf9f85f7231223e7f1c38c16e5504835b3 |
| turbo-cache-control | no-preview |
| go-import | github.com/PowerShell/PSScriptAnalyzer git https://github.com/PowerShell/PSScriptAnalyzer.git |
| octolytics-dimension-user_id | 11524380 |
| octolytics-dimension-user_login | PowerShell |
| octolytics-dimension-repository_id | 33149177 |
| octolytics-dimension-repository_nwo | PowerShell/PSScriptAnalyzer |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 33149177 |
| octolytics-dimension-repository_network_root_nwo | PowerShell/PSScriptAnalyzer |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | ecfd63ca125ec74b42f74eeb158b3fa081c8c497 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width