Title: `PSPlaceOpenBrace` and `PSPlaceCloseBrace` leave trailing whitespace when expanding one-line blocks · Issue #2210 · PowerShell/PSScriptAnalyzer · GitHub
Open Graph Title: `PSPlaceOpenBrace` and `PSPlaceCloseBrace` leave trailing whitespace when expanding one-line blocks · Issue #2210 · PowerShell/PSScriptAnalyzer
X Title: `PSPlaceOpenBrace` and `PSPlaceCloseBrace` leave trailing whitespace when expanding one-line blocks · Issue #2210 · PowerShell/PSScriptAnalyzer
Description: Steps to reproduce Format a one-line block with IgnoreOneLineBlock = $false: Invoke-Formatter -ScriptDefinition "if (`$x) { BREAK }" -Settings @{ IncludeRules = @( 'PSPlaceOpenBrace' 'PSPlaceCloseBrace' 'PSUseConsistentIndentation' 'PSUs...
Open Graph Description: Steps to reproduce Format a one-line block with IgnoreOneLineBlock = $false: Invoke-Formatter -ScriptDefinition "if (`$x) { BREAK }" -Settings @{ IncludeRules = @( 'PSPlaceOpenBrace' 'PSPlaceCloseB...
X Description: Steps to reproduce Format a one-line block with IgnoreOneLineBlock = $false: Invoke-Formatter -ScriptDefinition "if (`$x) { BREAK }" -Settings @{ IncludeRules = @( 'PSPlaceOpenBrace...
Opengraph URL: https://github.com/PowerShell/PSScriptAnalyzer/issues/2210
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`PSPlaceOpenBrace` and `PSPlaceCloseBrace` leave trailing whitespace when expanding one-line blocks","articleBody":"Steps to reproduce\n------------------\n\nFormat a one-line block with `IgnoreOneLineBlock = $false`:\n\n```powershell\nInvoke-Formatter -ScriptDefinition \"if (`$x) { BREAK }\" -Settings @{\n IncludeRules = @(\n 'PSPlaceOpenBrace'\n 'PSPlaceCloseBrace'\n 'PSUseConsistentIndentation'\n 'PSUseCorrectCasing'\n )\n Rules = @{\n PSPlaceOpenBrace = @{\n Enable = $true\n OnSameLine = $true\n NewLineAfter = $true\n IgnoreOneLineBlock = $false\n }\n PSPlaceCloseBrace = @{\n Enable = $true\n NewLineAfter = $true\n IgnoreOneLineBlock = $false\n }\n PSUseConsistentIndentation = @{ Enable = $true }\n PSUseCorrectCasing = @{ Enable = $true }\n }\n}\n```\n\nExpected behavior\n-----------------\n\nExpanding the block should not introduce trailing whitespace:\n\n```powershell\nif ($x) {\n break\n}\n```\n\nActual behavior\n---------------\n\nThe output contains a trailing space after `break`. The `␠` below marks that space:\n\n```text\nif ($x) {\n break␠\n}\n```\n\nThe brace corrections replace only the brace tokens. The spaces that separated the one-line content from the braces survive as trailing whitespace after the block is expanded.\n\nPowerShell/PSScriptAnalyzer#1992 and merged PowerShell/PSScriptAnalyzer#1993 are related, but not duplicates. They make `PSAvoidTrailingWhitespace` available to `Invoke-Formatter` when explicitly configured. They do not prevent `PSPlaceOpenBrace` and `PSPlaceCloseBrace` from introducing trailing whitespace. Callers should not need a separate cleanup rule to remove whitespace created by the formatter itself.\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:54:52Z","url":"https://github.com/PowerShell/PSScriptAnalyzer/issues/2210"}
| 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:c5d3ff6d-e6ad-535c-62ad-e06bfeff4174 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 879C:10BEBB:142CC3A:1C6FC8C:6AFCE4A3 |
| html-safe-nonce | cf5253a5cfa30cbcdb63ac361e3bae69c76bb73d62d9a0daf1abdfa164d48e17 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4NzlDOjEwQkVCQjoxNDJDQzNBOjFDNkZDOEM6NkFGQ0U0QTMiLCJ2aXNpdG9yX2lkIjoiNTQxODc3ODE0ODY5OTQzNDU5IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 675032a9cbc17d64543ecc2922558c27fdc48f764cab769d9f7ab0ce0fc7e117 |
| hovercard-subject-tag | issue:5236778933 |
| 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/2210/issue_layout |
| twitter:image | https://opengraph.githubassets.com/5e10fc1d1c285632b2daf02105679f0e99c4eba4d121ab4ba46f3f3c06a9c7e7/PowerShell/PSScriptAnalyzer/issues/2210 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/5e10fc1d1c285632b2daf02105679f0e99c4eba4d121ab4ba46f3f3c06a9c7e7/PowerShell/PSScriptAnalyzer/issues/2210 |
| og:image:alt | Steps to reproduce Format a one-line block with IgnoreOneLineBlock = $false: Invoke-Formatter -ScriptDefinition "if (`$x) { BREAK }" -Settings @{ IncludeRules = @( 'PSPlaceOpenBrace' 'PSPlaceCloseB... |
| 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