Repository navigation
feat: scroll the diff view with J/K hotkeys - #224
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds lazygit-style vertical scrolling of the diff viewport using J/K, allowing users to scroll the diff without switching focus away from the tree/TOC pane.
Changes:
- Introduces new keymap actions
scroll_diff_down/scroll_diff_upwith default bindingsJ/Kand help entries. - Adds model logic to scroll the diff viewport by a fixed step and keep the diff cursor pinned to a visible row.
- Adds UI tests covering
J/Kbehavior with both tree and diff panes focused, including no-op behavior when the diff fits.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| app/ui/diffnav.go | Adds diff-viewport line scrolling helper and routes new scroll actions from both diff- and tree-focused handlers. |
| app/ui/diffnav_test.go | Adds tests ensuring J/K scroll the diff viewport without changing focus or tree selection. |
| app/keymap/keymap.go | Defines new actions, validates them, adds help text, and binds J/K by default. |
| app/keymap/keymap_test.go | Extends keymap tests to cover the new default bindings and action validity. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
umputun
left a comment
There was a problem hiding this comment.
tests/lint/race all green, CI green, no correctness issues. Copilot found nothing either. Three asks before merge:
-
reuse the wheel step.
diffScrollStep = 2now sits next toWheelStep = 3(mouse wheel) and the shift+wheel half-page, so there are three different small-scroll steps in the same space. DropdiffScrollStepand pass the existingwheelStepintoscrollDiffViewportLineso J/K matches the wheel. Lazygit uses 2, but staying consistent with revdiff's own wheel step is better here. -
docs need updating in this PR. The in-app help auto-generates from
defaultDescriptions()so the overlay is covered, but the hand-maintained docs are stale. New bindings/actions need to go into:- keybindings tables:
README.md,site/docs.html,.claude-plugin/skills/revdiff/references/usage.md,plugins/codex/skills/revdiff/references/usage.md - actions lists:
README.md,site/docs.html,.claude-plugin/skills/revdiff/references/config.md,plugins/codex/skills/revdiff/references/config.md
the two plugin copies must stay byte-identical to each other.
- keybindings tables:
-
assert the cursor pin.
TestModel_JKScrollsDiffViewportchecksYOffset, focus, and tree selection but neverm.nav.diffCursor. The pin is the reasonscrollDiffViewportLineexists over the plainscrollDiffViewportBy, and the test would still pass if the pin were dropped. Add adiffCursorassertion after the J press.
Drops diffScrollStep so J/K matches the mouse-wheel step rather than introducing a third small-scroll distance.
The pin is why scrollDiffViewportLine exists over plain scrollDiffViewportBy; without this assertion the test passed even if the pin were dropped.
Add the J/K keybinding row and scroll_diff_down/scroll_diff_up actions to README, site/docs.html, and both plugin reference copies (claude + codex).
|
@umputun thanks for the quick feedback. Just made the requested changes - ready for another look. |
umputun
left a comment
There was a problem hiding this comment.
all three asks addressed: wheel-step reuse (diffScrollStep dropped, J/K uses wheelStep), docs across all six locations (the two config.md copies byte-identical), and the diffCursor pin assertion after the J press.
This mimics behavior in lazygit: you can quickly scroll through the diff without changing focus to the diff view. I've found this is a nice improvement as I can quickly change files and scroll through their diffs with fewer keystrokes. I opted to scroll by 2 lines at a time for parity with lazygit.