Repository navigation
fix(cockpit): show a changed block as its removals, then its additions - #96
Merged
Merged
Conversation
diff2html's line matching pairs each removed line with the added line it most resembles and prints the pairs in turn, so a rewritten paragraph read as - + - + and neither version could be read through. Regroup each run of changed rows the way GitHub lays it out — every removal, then every addition — keeping the word marks the matching produced. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jtomaszewski
approved these changes
Nov 13, 2026
|
🎉 This PR is included in version 1.8.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
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.
Problem
In the cockpit's diff, a rewritten paragraph showed its removed and added lines one after another (
- + - + - +), so you couldn't read the old text or the new text from start to finish. GitHub shows the whole removed block first, then the whole added block.Fix
diff2html pairs each removed line with the added line it most resembles, which is how it marks the changed words, and then prints the pairs in turn.
groupChangedRows(web/src/diffrows.ts) reorders the rendered rows: within each run of changed lines, all removals first, then all additions, each side in its original order. Context lines and@@headers still split runs, so no change moves past unchanged text. The word marks stay because only the row order changes.Verification
web/src/diffrows.test.ts: a block is grouped, the word marks survive, and nothing moves across context or a hunk headerpnpm typecheck && pnpm testpass🤖 Generated with Claude Code
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.