Skip to content

feat: show a diff side by side, the old version facing the new, and stage lines from either side - #50

Merged
Lars- merged 1 commit into
mainfrom
feat/side-by-side-diff
Nov 17, 2026
Merged

Lars- merged 1 commit into
mainfrom
feat/side-by-side-diff

Conversation

@Lars-

@Lars- Lars- commented Nov 17, 2026

Copy link
Copy Markdown
Owner

What this changes

A diff can now be shown side by side: a "Side by side" button above it puts the old version on the left and the new one on the right. Unchanged lines are on both sides, a removed line faces the added line that replaced it (the same pairing the word highlights use), and a line that replaces nothing has an empty space beside it. Each side shows its own line numbers, the changed words still stand out, and lines can be picked for staging or discarding from either side, as before. The choice applies to every diff, also the one under a file's history, and lasts between runs.

This is part 2 of "Better diffs" on the roadmap; syntax colouring and images stay for part 3.

How it is tested

  • Hunk::side_by_side in core gets a unit test on two diffs: blocks with more added than removed lines and the other way around, and "No newline at end of file" on the side of its line.

  • A new app test opens a diff, checks the lines are one under the other, turns on side by side and checks from what is painted that the old line faces the new one, an unpaired added line is on the right, a context line is on both sides and the changed words are still marked; then it clicks a line on each side, stages them and reads the index; the next diff is side by side too, until the button turns it off. It fails without the pairing.

  • Tried in the app on Linux: staging one line from each side, the history view, and the choice surviving a restart.

  • cargo fmt --all, cargo clippy --workspace --all-targets -- -D warnings and cargo test --workspace pass

  • It adds as little code as the change needs, and removes what it makes unnecessary

  • Nothing in it comes from GitKraken or another closed-source client (see CONTRIBUTING.md)

@Lars-
Lars- merged commit f4f959d into main Nov 17, 2026
7 checks passed
@Lars- Lars- mentioned this pull request Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant