Skip to content

base: Stop auto scroll once the text selection gesture has ended - #2941

Merged
madcodelife merged 1 commit into
mainfrom
text-selection-click-auto-scroll
Sep 4, 2026
Merged

madcodelife merged 1 commit into
mainfrom
text-selection-click-auto-scroll

Conversation

@madcodelife

Copy link
Copy Markdown
Member

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. base: Move TextView to gpui-base #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-base: Move TextView to gpui-base #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

  • pointer_moves_after_a_click_do_not_auto_scroll fails 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 warnings and cargo fmt --check are clean.

🤖 Generated with Claude Code

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@madcodelife
madcodelife merged commit 12e21c9 into main Sep 4, 2026
9 checks passed
@madcodelife
madcodelife deleted the text-selection-click-auto-scroll branch September 4, 2026 03:34
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>
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