Skip to content

fix(review): a mouse selection made upward no longer scrolls the diff on release - #198

Merged
backnotprop merged 1 commit into
mainfrom
fix/upward-drag-jump
Nov 24, 2026
Merged

backnotprop merged 1 commit into
mainfrom
fix/upward-drag-jump

Conversation

@backnotprop

Copy link
Copy Markdown
Contributor

What users saw

When you drag up in the code review (press on a lower line, move up, let go), the view jumps when you let go. The selected lines end up on the last rows of the pane, with the toolbar just above them. A drag down did not do this. It happens whenever the diff is scrolled away from its top, which is most of the time on a long review. It was reproduced in 0.11.2 at 200x60 on a 13-file review: the selection moved 8 rows down, and up to a full screen when the view was scrolled further down.

Cause

On release, Screen::release called Diff::select (diffs-rs select_range, which puts the cursor on the last line) and then Diff::reveal on the first line. In diffs-rs 0.2.3, App::reveal_source ends with self.visible.clear(). The second reveal then finds no drawn rows, treats the first line as off screen, and sets top to that line minus height - 4 rows. A shift-click above the pressed line takes the same path. The existing tests missed it because their diffs start at line 1, where top cannot go up.

Fix

Diff::select_from makes the selection the way v does. It clicks the pressed line, starts the selection, clicks the line the pointer reached, and ends the selection, at the rows the last frame drew. Nothing is revealed, so nothing scrolls. The viewer also records the cursor's true screen row. Without that, a footer that changes height when lines get selected (narrow panes) moved the view a few rows, even for downward drags sent as one burst. The old path stays for an end that is off screen: a drag held past the pane's edge.

Tests

New review/tests/release_view.rs. The diff is scrolled 8 wheel notches first, then:

  • drags up, down and along one row, and a drag up after a drag down
  • at 200x60, 250x70, 180x50, 120x40 and 100x30
  • split, unified, wrap on, and unified with wrap on
  • reports one per frame and in one burst
  • a shift-click above the pressed line

Every case checks that each pane row shows the same line after the release. All of these failed before the fix, and all pass now.

… on release

Letting go of a drag that went up put the selected lines on the pane's last
rows: the view jumped up by up to a screen. The release asked diffs-rs to
select the lines (cursor on the last) and then to reveal the first. The
select forgets the rows the last frame drew, so the reveal saw the first line
as off screen and scrolled it to four rows above the pane's bottom. A
shift-click above the pressed line did the same. The tests never saw it
because their diffs start at the top, where the view cannot go further up.

A selection is now made the way `v` makes one, with clicks on its two ends
where the last frame drew them: nothing scrolls, and the viewer keeps the
right screen row for the cursor when a narrow footer changes height. The old
way stays for an end that is off screen (a drag held past the pane's edge).
@backnotprop
backnotprop added this pull request to the merge queue Nov 24, 2026
Merged via the queue into main with commit 08082aa Nov 24, 2026
3 checks passed
@backnotprop
backnotprop deleted the fix/upward-drag-jump branch November 24, 2026 03:22
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