Repository navigation
Drop the blank lines around a braced member body [patch] - #182
Open
matt-edmondson wants to merge 1 commit into
Open
matt-edmondson wants to merge 1 commit into
matt-edmondson wants to merge 1 commit into
Conversation
WriteBody left blank lines out only when deciding a body's shape, then spliced the factory's whole output. A factory that ended with NewLine() (the pattern #133 had in mind) added a second blank line between members, and one that started with NewLine() put a blank line between the signature and its opening brace. Leading and trailing blank lines are now trimmed before the body is spliced, for braced and comment-only bodies alike; blank lines inside the body are kept. Fixes #180 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW3rHMVCnBN5uuK5G3N
|
This was referenced Nov 4, 2026
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.



Fixes #180
What was wrong
TemplateRendering.WriteBodyleft blank lines out only when it was deciding a body's shape (thecontentLinesfilter). For a braced body it then spliced the factory's whole output. So:NewLine(), the pattern Render a body of only blank lines as an empty block #133 had in mind, added a second blank line between membersNewLine()put a blank line between the signature and its{Change
WriteBodynow trims leading and trailing empty lines before it splices. This covers both the braced path and the comment-only path (Brace a member body that holds only comments or directives [patch] #161). Blank lines inside the body are kept.SpliceFragmentis split so that already-split lines can be spliced (SpliceLines).Skip/Takerather than a range on the array, because the netstandard2.0 target has noRuntimeHelpers.GetSubArray.Tests
ABracedBodyDropsTheBlankLinesAroundIt: the repro from the issue, inside a class. It expects one blank line between members and each{directly under its signature.ABracedBodyKeepsItsInteriorBlankLinesWhenItsOuterOnesAreDroppedACommentOnlyBodyDropsTheBlankLinesAroundItAll three fail with the fix reverted. The full suite passes with it (332/332,
dotnet teston Linux).Generated by Claude Code