Repository navigation
fix(review): a mouse selection made upward no longer scrolls the diff on release - #198
Merged
Merged
Conversation
… 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).
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.
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::releasecalledDiff::select(diffs-rsselect_range, which puts the cursor on the last line) and thenDiff::revealon the first line. In diffs-rs 0.2.3,App::reveal_sourceends withself.visible.clear(). The second reveal then finds no drawn rows, treats the first line as off screen, and setstopto that line minusheight - 4rows. A shift-click above the pressed line takes the same path. The existing tests missed it because their diffs start at line 1, wheretopcannot go up.Fix
Diff::select_frommakes the selection the wayvdoes. 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: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.