Repository navigation
fix: level sibling lines when rebasing a charwise block - #21
Merged
Merged
Conversation
A charwise yank that starts mid-line drops the first line's leading whitespace, so rebase_charwise_block has to guess where that line sat relative to the inner lines. The old guess treated every block that never dedents below its first inner indent as an opener plus nested body, which over-indented sibling statements by the block's original base after the shift to the target indent. Ask the scope-opener heuristics about the stripped first line instead: opener-looking lines (trailing brace/colon, keyword openers, tag openers) keep the nesting guess, while anything else is re-padded to the minimum inner indent so siblings land level after the uniform delta. The caller now passes its buffer through so the heuristics read the right commentstring. Still a guess, but it matches the common yank patterns far better. Refs #17
nemanjamalesija
changed the base branch from
fix/trailing-comment-scope-detection
to
main
July 5, 2026 11:59
1 task
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.
Refs #17, does not close it, waiting for reporter confirmation. Builds on the trailing comment fix branch, merge that one first.
A charwise yank that starts mid line drops the first line's leading whitespace, so the paste conversion has to guess the block's structure. The old guess always nested the inner lines under line 1, which over indented siblings:
rebase_charwise_blocknow checks whether the first line looks like a scope opener. Opener looking first lines (if x:,foo() {, tag openers) keep the nesting guess. Non opener first lines are rebased to the minimum inner indent so siblings land level. Blank first lines keep the old behavior since they carry no evidence either way.Known tradeoff, stated in the doc comment: continuation constructs whose first line does not end in an opener token (aligned call arguments, method chains) are now leveled too. The structure is genuinely ambiguous once the first line's indent is gone.
Tests: four new regression cases including the reported sibling scenario and a blank first line guard. Full suite green.