Repository navigation
Commit 12054f5
base: Stop drag auto scroll when the content mask collapses (longbridge#2902)
## Summary
- Fix a crash in `WindowSelectionState::update_auto_scroll`:
drag-selection auto scroll can scroll the anchor's clipping viewport
away, and once the registered content mask collapses below 2px, clamping
the drag position into it panics (`Ord::clamp`: `assertion failed: min
<= max`).
- Stop the anchor auto scroll when the mask is narrower than twice the
hit-test inset (extracted as `HIT_TEST_INSET`) — there is nothing left
to scroll.
- Add a regression test: begin a drag on a normal registration,
re-register with a collapsed content mask, then drive `update_in_window`
past the viewport edge.
## Test plan
- [x] `drag_auto_scroll_stops_when_the_content_mask_collapses` panics
before the fix and passes after.
- [x] `cargo test -p gpui-base --lib text_selection` — all 48 tests
pass.
- [x] `cargo run -p gpui-base --example components text-selection` —
drag-selection auto scroll still behaves normally.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>1 parent a3f7bb2 commit 12054f5
1 file changed
Lines changed: 52 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1472 | 1472 | | |
1473 | 1473 | | |
1474 | 1474 | | |
| 1475 | + | |
| 1476 | + | |
| 1477 | + | |
| 1478 | + | |
| 1479 | + | |
| 1480 | + | |
| 1481 | + | |
| 1482 | + | |
| 1483 | + | |
1475 | 1484 | | |
1476 | 1485 | | |
1477 | 1486 | | |
| |||
1480 | 1489 | | |
1481 | 1490 | | |
1482 | 1491 | | |
1483 | | - | |
1484 | | - | |
| 1492 | + | |
| 1493 | + | |
1485 | 1494 | | |
1486 | 1495 | | |
1487 | | - | |
1488 | | - | |
| 1496 | + | |
| 1497 | + | |
1489 | 1498 | | |
1490 | 1499 | | |
1491 | 1500 | | |
| |||
3095 | 3104 | | |
3096 | 3105 | | |
3097 | 3106 | | |
| 3107 | + | |
| 3108 | + | |
| 3109 | + | |
| 3110 | + | |
| 3111 | + | |
| 3112 | + | |
| 3113 | + | |
| 3114 | + | |
| 3115 | + | |
| 3116 | + | |
| 3117 | + | |
| 3118 | + | |
| 3119 | + | |
| 3120 | + | |
| 3121 | + | |
| 3122 | + | |
| 3123 | + | |
| 3124 | + | |
| 3125 | + | |
| 3126 | + | |
| 3127 | + | |
| 3128 | + | |
| 3129 | + | |
| 3130 | + | |
| 3131 | + | |
| 3132 | + | |
| 3133 | + | |
| 3134 | + | |
| 3135 | + | |
| 3136 | + | |
| 3137 | + | |
| 3138 | + | |
| 3139 | + | |
| 3140 | + | |
| 3141 | + | |
| 3142 | + | |
| 3143 | + | |
| 3144 | + | |
| 3145 | + | |
3098 | 3146 | | |
3099 | 3147 | | |
3100 | 3148 | | |
| |||
0 commit comments