Fix closing brace indentation with --trimwhitespace nonblank-lines#2477
Merged
Fix closing brace indentation with --trimwhitespace nonblank-lines#2477
--trimwhitespace nonblank-lines#2477Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #2477 +/- ##
===========================================
- Coverage 95.30% 95.29% -0.01%
===========================================
Files 167 167
Lines 25330 25337 +7
===========================================
+ Hits 24141 24146 +5
- Misses 1189 1191 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…cope Co-authored-by: calda <1811727+calda@users.noreply.github.com> Agent-Logs-Url: https://github.com/nicklockwood/SwiftFormat/sessions/aa04af11-ceda-44a5-a717-a8e620ad305d
Copilot
AI
changed the title
[WIP] Fix indentation of closing brace in deletePackage function
Fix closing brace indentation with Mar 25, 2026
--trimwhitespace nonblank-lines
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
When
--trimwhitespace nonblank-linesis set, blank lines before closing braces retain trailing whitespace.blankLinesAtEndOfScopewould remove only the linebreak token when eliminating such a blank line, leaving the trailing space stranded on the same line as the closing brace's indent token. Theindentrule then replaced that stranded space rather than the brace's own indent, producing doubled indentation.Changes
Sources/FormattingHelpers.swift— InremoveTrailingBlankLinesIfPresent, after removing the last linebreak of a trailing blank line, also remove any trailing whitespace token that preceded it (identified by the patternlinebreak → space → linebreak).Tests/Rules/BlankLinesAtEndOfScopeTests.swift— AddedtestBlankLinesAtEndOfScopeRemovedWithTrailingWhitespacecovering blank lines with trailing whitespace before a closing brace undertruncateBlankLines: false.Example
Original prompt
--trimwhitespace nonblank-lines#2465✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.