Repository navigation
fix(review): a drag selection no longer races the diff to the bottom - #193
Merged
Merged
Conversation
A drag past the diff pane's top or bottom moved the cursor a line for every mouse report, with no limit on the rate and no stop at the hunk the selection is kept in. Terminals in a window can report every pixel the pointer moves, so a drag that touched the footer row scrolled hundreds of lines in a moment, through the other files to the end of the diff. Several reports also arrive between two frames, and each click after a scroll was hit-tested against the stale frame, so a burst ended on other lines than the same reports one per frame. Now a report for the cell already reported does nothing, only a line of code takes the drag's click, and no report scrolls. Held past an edge, the view scrolls a line per 50 ms on the event loop's tick, and only while the anchor's hunk has lines that way.
…sense mouse reports are ignored The document screen scrolled one row for every drag report past the text's top or bottom, so a terminal that reports each pixel raced the document to its end. It now follows the review: a report for the cell already reported does nothing, no report scrolls, and held past an edge the document scrolls a row per 50 ms on the loop's tick until it ends. The edge timer moves to ui::drag, shared by both screens. Both screens now ignore a mouse report for a cell outside the terminal (pixel positions, a broken encoding) instead of reading it as the pointer past the bottom. A release there still ends a drag, at the nearest cell.
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.
Reported from a terminal in a window (Rex, possibly Herdr): "whenever I select text, it all just scrolls to the bottom." This fixes the code review (
plannotator-tui review) and the document screen (files, folders and agent replies).Cause
review/mouse.rsdrag_to(v0.11.1, lines 188-191) ranCommand::UporCommand::Downfor every drag report whose row was above or below the diff pane:GHOSTTY_MOUSE_ENCODER_OPT_TRACK_LAST_CELL, so it does this. Our tmux tests sent one report per cell, with a frame between reports, so they did not show it.Engine::row_atand clicks use the last drawn frame). So a burst ended on other lines than the same reports one per frame: 12..18 against 12..28 in the new test.A drag that stays inside the pane did not scroll in v0.11.1, in bursts too. This was checked in a test and in the release binary.
Reproduction (v0.11.1 release binary, private tmux, 160x45)
Four files of 200 lines, each changed in blocks (first hunk: new lines 1..92). All reports were sent in one
send-keys -lstring:ESC[<32;60..62;45M)file1.pyline 146Change
STEP(50 ms) fromScreen::tick. It scrolls only while the cursor is in the anchor's hunk and the hunk has more lines in that direction. While a drag is held past an edge, the loop wakes every 50 ms.review/mouse/edge.rs.Diff::hunk_spannow also returns the hunk's index.Document screen (second commit)
app/input.rs(v0.11.1, lines 617-621) scrolled one row for each drag report past the text's top or bottom: 100 reports on the last row scrolled 100 rows, in v0.11.0 too. It now follows the same rules (app/drag.rs):The edge timer (
Edge,STEP) is inui::drag. Both screens use it.Focus reports (
ESC[I/ESC[O) during a drag scroll nothing, in v0.11.0, v0.11.1 and here.Reports outside the terminal
Both screens ignore a mouse report for a cell outside the frame last drawn: pixel positions, rows past the terminal,
u16::MAX. Before, such a report was read as the pointer past the bottom. A release there still ends the drag, at the nearest cell, so no drag stays held (ui::drag::on_screen).Tests
New, in
review/tests/drag_burst.rs(160x45, split diff):a_burst_of_drag_reports_inside_the_pane_moves_no_view_and_selects_press_to_pointerreports_in_one_burst_end_as_the_same_reports_one_per_frame(fails on main)reports_for_the_pressed_cell_leave_a_click_a_click(fails on main)a_press_on_any_row_of_the_pane_leaves_the_view_where_it_isheld_past_the_bottom_the_view_scrolls_a_line_per_step_however_many_reportsheld_past_the_bottom_the_view_stops_at_the_end_of_the_drags_hunkother_buttons_the_horizontal_wheel_and_focus_reports_during_a_drag_scroll_nothingreports_outside_the_terminal_are_ignored_and_a_release_there_still_ends_the_dragNew, in
app/drag_tests.rs(document screen, 120x40):drag_reports_in_a_burst_scroll_nothing_and_end_as_the_same_reports_one_per_frameheld_past_the_bottom_the_document_scrolls_a_row_per_step_however_many_reportsheld_past_the_bottom_the_document_stops_at_its_endreports_outside_the_terminal_are_ignored_and_a_release_there_still_ends_the_dragdragging_past_the_bottom_scrolls_and_keeps_selectingandan_upward_drag_that_scrolled_keeps_the_view_where_it_went_on_releasenow hold the drag on the timer, not with one report per step. They now drag over the footer row, not over rows past the terminal, which are now ignored.Not verified
The fix was not run in a real Rex or Herdr window. The link to the report is inferred: the bug needs the pointer above or below the pane (the header row or the footer row), which a drag toward the last visible line easily reaches.
The document-screen change was checked by its tests only. The tmux runs above were made before it, and the release binary was not run again.