Skip to content

feat: scroll the diff view with J/K hotkeys - #224

Merged
umputun merged 4 commits into
umputun:masterfrom
steve-mackinnon:feat/tree-focus-diff-scroll
Jun 6, 2026
Merged

umputun merged 4 commits into
umputun:masterfrom
steve-mackinnon:feat/tree-focus-diff-scroll

Conversation

@steve-mackinnon

Copy link
Copy Markdown
Contributor

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.

  • Adds action items to the help page
  • Adds tests to verify the behavior with both tree and diff view focused

@steve-mackinnon
steve-mackinnon requested a review from umputun as a code owner June 6, 2026 19:19
@steve-mackinnon steve-mackinnon changed the title Scroll the diff view with J/K hotkeys feat: scroll the diff view with J/K hotkeys Jun 6, 2026
@umputun
umputun requested a review from Copilot June 6, 2026 19:21

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_up with default bindings J / K and 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/K behavior 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 umputun left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tests/lint/race all green, CI green, no correctness issues. Copilot found nothing either. Three asks before merge:

  1. reuse the wheel step. diffScrollStep = 2 now sits next to WheelStep = 3 (mouse wheel) and the shift+wheel half-page, so there are three different small-scroll steps in the same space. Drop diffScrollStep and pass the existing wheelStep into scrollDiffViewportLine so J/K matches the wheel. Lazygit uses 2, but staying consistent with revdiff's own wheel step is better here.

  2. 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.

  3. assert the cursor pin. TestModel_JKScrollsDiffViewport checks YOffset, focus, and tree selection but never m.nav.diffCursor. The pin is the reason scrollDiffViewportLine exists over the plain scrollDiffViewportBy, and the test would still pass if the pin were dropped. Add a diffCursor assertion 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).
@steve-mackinnon
steve-mackinnon requested a review from umputun June 6, 2026 21:39
@steve-mackinnon

Copy link
Copy Markdown
Contributor Author

@umputun thanks for the quick feedback. Just made the requested changes - ready for another look.

@umputun umputun left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@umputun
umputun merged commit f553105 into umputun:master Jun 6, 2026
2 checks passed
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.

3 participants