base: Stop auto scroll once the text selection gesture has ended - #2941
Merged
Merged
Conversation
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
feigeCode
pushed a commit
to feigeCode/gpui-kit
that referenced
this pull request
Sep 5, 2026
…gbridge#2941) ## Summary - Fix markdown (and any other `TextView`) scrolling on its own after a single click: click on text, then move the pointer toward the top or bottom edge of the viewport, and the view starts auto scrolling and keeps going. - Root cause: `WindowSelectionState::end()` keeps the anchor after mouse up so a shift-click can extend it, and only clears `is_selecting`. longbridge#2881 moved the auto scroll call out of `update_impl` (which has the `is_selecting` guard) into `update_in_window`, so `update_auto_scroll` ran on every pointer move with a live anchor. Once the pointer was in the edge zone it started the anchor auto scroll, and the synthesized `ScrollWheelEvent` re-entered the same path and kept it alive. - Guard `update_auto_scroll` on `is_selecting`, restoring the pre-longbridge#2881 behavior: only a live drag may scroll. - Add the regression test `pointer_moves_after_a_click_do_not_auto_scroll`: begin a gesture on text, end it, then drive `update_in_window` past the viewport edge and assert auto scroll stays idle. The fix and the test were written with Claude Code. ## Test plan - [x] `pointer_moves_after_a_click_do_not_auto_scroll` fails before the fix and passes after. - [x] `cargo test -p gpui-base --lib text_selection` — all 49 tests pass. - [x] `cargo test -p gpui-component --lib text::window_selection` — all 51 tests pass, including drag auto scroll in both directions. - [x] `cargo clippy -p gpui-base --all-targets -- --deny warnings` and `cargo fmt --check` are clean. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
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.
Summary
TextView) scrolling on its own after a single click: click on text, then move the pointer toward the top or bottom edge of the viewport, and the view starts auto scrolling and keeps going.WindowSelectionState::end()keeps the anchor after mouse up so a shift-click can extend it, and only clearsis_selecting. base: Move TextView to gpui-base #2881 moved the auto scroll call out ofupdate_impl(which has theis_selectingguard) intoupdate_in_window, soupdate_auto_scrollran on every pointer move with a live anchor. Once the pointer was in the edge zone it started the anchor auto scroll, and the synthesizedScrollWheelEventre-entered the same path and kept it alive.update_auto_scrollonis_selecting, restoring the pre-base: Move TextView to gpui-base #2881 behavior: only a live drag may scroll.pointer_moves_after_a_click_do_not_auto_scroll: begin a gesture on text, end it, then driveupdate_in_windowpast the viewport edge and assert auto scroll stays idle.The fix and the test were written with Claude Code.
Test plan
pointer_moves_after_a_click_do_not_auto_scrollfails before the fix and passes after.cargo test -p gpui-base --lib text_selection— all 49 tests pass.cargo test -p gpui-component --lib text::window_selection— all 51 tests pass, including drag auto scroll in both directions.cargo clippy -p gpui-base --all-targets -- --deny warningsandcargo fmt --checkare clean.🤖 Generated with Claude Code