Handle drags: restore cross-line selection via relative line mapping
The line-lock from the previous fix made anchors immovable across lines — dragging a handle vertically no longer extended the selection, losing the native multi-line behaviour. New contract: a handle anchor moves RELATIVE to its own visual line. The finger's vertical displacement from the grab position, in whole visual line heights, selects the target line (under half a line: the anchor's own line); the finger's x is projected onto that line. A stationary or horizontal drag never moves the anchor off its line (the grab-box press stays safe — the original bug is gone), while a deliberate vertical drag walks the anchor across lines. The mapping is relative, not the finger's absolute line, because the 48dp grab box is centred below the line: a low press tracking the finger's absolute line would first drag the anchor the wrong way, through a collapse, before reaching the anchor's line. Verified on device: end handle dragged down extends the selection across the newline; start handle dragged up extends it onto the previous line; horizontal drags still shrink along the line without clearing. Tests mutation-verified against both the pre-fix mapping and the absolute-finger-line variant. Docs section 17 updated.
This commit is contained in:
+25
-16
@@ -949,11 +949,10 @@ tapping elsewhere).
|
||||
|
||||
## 17. Handle drags, menu anchoring, and the left-edge gesture (2026-08-18)
|
||||
|
||||
**Line projection for handle drags.** A selection handle's 48dp grab box
|
||||
(straddling two visual lines, because the teardrop hangs off the line's
|
||||
bottom edge) is larger than the line it belongs to. A finger in the lower
|
||||
half of the box maps, by pure y-to-line, to the NEIGHBOURING line.
|
||||
Mapping the finger to its own line was fatal for a start-handle drag: the
|
||||
**Relative line mapping for handle drags.** A selection handle's 48dp grab
|
||||
box is centred BELOW its line (the teardrop hangs off the line's bottom
|
||||
edge), so a press usually lands on the neighbouring line. Mapping the
|
||||
finger to its own line was fatal for a start-handle drag: the
|
||||
neighbouring-line byte is usually past the other handle, the clamp
|
||||
collapses the selection to zero length, the selection is cleared — and a
|
||||
cleared selection un-registers the drag op, so Gio's router silently
|
||||
@@ -961,18 +960,28 @@ stops delivering drag events to it (an inactive handler is deleted at the
|
||||
next frame boundary without a cancel). Every downstream symptom — the
|
||||
"stream cutoff", a tap landing on release, the system back gesture
|
||||
firing on subsequent edge swipes — was a consequence of that single
|
||||
collapse, not a system-side touch filter.
|
||||
collapse, not a system-side touch filter. The first attempt at a fix
|
||||
locked the anchor to its own line entirely, which removed the bug but
|
||||
also removed the native ability to drag a handle across lines.
|
||||
|
||||
Contract: a handle drag projects the finger's X onto the ANCHOR's own
|
||||
visual line (the line the handle belongs to, resolved the same way the
|
||||
renderer resolves the handle position). The anchor therefore never
|
||||
crosses a line during a handle drag; vertical finger movement is ignored.
|
||||
The trade-off vs. native (native can walk the anchor to another line by
|
||||
dragging across lines) is accepted: the reported bug was worse than the
|
||||
sacrifice, and body drags still move whole selections across lines.
|
||||
Regression: `TestSelDrag_*_PressOnLineBelow_*` in
|
||||
`touch_selection_test.go` (both mutation-verified against the pre-fix
|
||||
mapping).
|
||||
Contract: a handle anchor moves RELATIVE to its own visual line. The
|
||||
finger's vertical displacement from the GRAB position, in whole visual
|
||||
line heights, selects the target line (less than half a line: the
|
||||
anchor's own line); the finger's X is projected onto that line. A
|
||||
stationary or horizontal drag therefore never moves the anchor off its
|
||||
line (the grab is safe), while a deliberate vertical drag walks the
|
||||
anchor across lines — dragging the end handle down extends the selection
|
||||
downward, dragging the start handle up extends it upward. The mapping is
|
||||
relative (displacement from the grab, not the finger's absolute line)
|
||||
precisely because the grab is usually a line or more below the anchor:
|
||||
tracking the finger's absolute line would first drag the anchor the wrong
|
||||
way, through a collapse, before it ever reached the anchor's line.
|
||||
Regressions in `touch_selection_test.go`:
|
||||
`TestSelDrag_StartHandle_PressOnLineBelow_KeepsSelection` (the original
|
||||
bug's geometry), `TestSelDrag_EndHandle_DragDownExtendsAcrossLines`,
|
||||
`TestSelDrag_StartHandle_DragUpExtendsToLineAbove` — all
|
||||
mutation-verified against both the pre-fix mapping and the
|
||||
absolute-finger-line variant.
|
||||
|
||||
**Menu anchors to the stable end.** While a start-handle drag is in
|
||||
progress the selection start is the moving end, so the menu anchors to
|
||||
|
||||
Reference in New Issue
Block a user