P0 RESIZE: a divider drag that starts on a snap follows the pointer from its first point

LA
13h ago
+92-1

Summary

P0 RESIZE (cmux-ad, Lawrence: "resizing columns and splits is still not very good"). A slow divider drag that starts on a snap did not move for the first 8 pt of the pointer, then jumped 8.5 pt to it.

Cause (films feat-5851715, bench build 5278851, kit cp/resize-keys-kit): a new split is an equal split, and the equal share and the half are snaps (DividerDragState.snaps, reach snapDistance 8 pt). The press itself sat inside the snap's reach, so the snap held the divider until the pointer was 8 pt away:

  • rkd-col-drag-2 (cmux22, CuaDriver hold_ms 0, start tier S): the divider stays at x 781 (576 | 576 pt) for 11 frames while the pointer moves about 13 pt, then jumps to 789.5 (8.5 pt): first move 10.94 refreshes (91.2 ms) after the mouse-down.
  • rkd-row-drag-slow: 99.5 ms, then 8.5 pt. rkd-col-drag-6 (0.5 pt per frame): 191 ms, then 8.5 pt.
  • Fast drags cover 8 pt in their first event: 24.5 ms, no jump. The main thread is idle in the gap (0.1-2.3 ms CPU per 10 ms, every tick 8.3 ms), and hold_ms 0 does not change it, so it is not the injector or a slow turn.

Fix: the snap the divider sits on at the press (DividerDragState.startSnap) holds nothing until the divider has left its reach once. A snap the divider arrives at still catches it (halves, thirds, the equal share, coming back to the start snap), and Shift (snap from any distance) keeps the start snap. The snap-on-arrival behavior itself stays a question for Lawrence (decisions.md).

Testing

New file DividerDragStartSnapTests (red first):

  • aDragThatStartsOnASnapFollowsThePointerFromItsFirstPoint (1, 3, 6, -3 pt from the half): the divider moves by that much. Red before the fix.
  • Guards (pass before and after): a divider that leaves its start snap and comes back snaps; a drag from 0.45 still snaps onto the half; Shift keeps the start snap.

Red / green / GUI proof and the before/after films: added below as they end.

Observed / Not run

  • Observed: the films and traces above.
  • Not run yet: red, green, GUI proof, after films.

Changelog

  • Fixed: dragging a divider from an equal split moves it with the pointer from the first point, instead of holding it for 8 pt and then jumping.

No capture: motion, filmed by the RESIZE KEYS kit (gallery feat-5851715-120x2).


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.


Summary by cubic

Fixes a divider drag that starts on a snap (like an equal split) so it follows the pointer from its first point, instead of holding still for 8 pt and then jumping 8.5 pt.

The snap the divider sits on at the press now holds nothing until the divider has left its reach once. Snaps the divider arrives at mid-drag still catch it, and Shift still snaps from any distance.

Testing

  • New DividerDragStartSnapTests verifies drags starting on the half move with the pointer (1, 3, 6, -3 pt), and that re-snapping on return, snapping on arrival, and Shift behavior are unchanged.