diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-19 20:54:11 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-20 00:01:22 -0300 |
| commit | 19f9e43dfa8bab618b2566a9060aef0ccb71fb0f (patch) | |
| tree | 502b3a9836d962dcfb2347d2ac15431c465b415a /core/mouse.zig | |
| parent | 1d6160072e474f8c07987ffe0b58de5d7576002b (diff) | |
| download | pardes-19f9e43dfa8bab618b2566a9060aef0ccb71fb0f.tar.gz pardes-19f9e43dfa8bab618b2566a9060aef0ccb71fb0f.zip | |
mouse: a drag or release in a kind's pane it grabbed, the pane since too short (or narrow) for a cell of body, is told its body's edge instead of tripping std.math.clamp's assertion: a press on a kind's body grabs it (`kind_grab`), and the drag and release after it are the kind's wherever they land, so `kindMouse` (core/mouse.zig) clamped the pointer into the body's range, which a step between the press and the drag (a resize, a pane put above it) can leave empty: `clamp(m.row, top, r.y + r.h -| 1)` with `top > r.y + r.h - 1` (the soak's one `lo <= hi` assertion, in a client's speculation at rtt 207: its typists press at random, resize the window to 16 rows and open panes; the same in the session, which a user could hit with a mouse kind's pane (a PDF) and a resize while a button is held, in Debug a panic, in ReleaseFast a wrong row); now `@min(m.row -| top, (r.y + r.h) -| top -| 1)` and the same for the column: equal to the clamp where the range has a cell, 0 where it has none; the test `a far client's drag in a kind's pane it grabbed, the pane since too short for a row of body: ...` (end of core/replica.zig, with a plain kind that takes the mouse and `runsHere`, its code in the client as a client with its library runs it) aborted on the base at core/mouse.zig's clamp (the press, a resize to 4 rows leaving the pane its tag alone, the drag) and passes: applied at once, confirmed, the client's digest the session's; gates on the seven together (the stack's top, load 18 to 50 beside them): tui core-test 855/999 (144 skipped), shell-test 1035/1038, pane-test 183/184, term-test 15/15, kitty-test 45/45, behaviour-test 275/275 and --replay 20 seeds 0 failures, process-test 3 of 144 (lspcomplete and lspcompletemoved, the base's, and headersweep-restored, which passes alone), gui unit-test 1633/1637 with the base's BaselineHarnessMismatch; replicas --clients 5 and --seeds 8: diverged 0, unequal 0, deltas wrong 0, quiet checks differed 0, unlisted stops 0, corpus 22 of 22, no leak report; the walk over every word and key passes; frame and perf gate against tree1 (farfaults): frames 77/77 byte-identical in Debug, unit-test 1633/1637, perfab corpus2x -0.087% (noise 0.092%, bar 0.4%, pictures identical), perfops 97 counts within 0.1% (largest +0.0329%)
Co-Authored-By: Claude Opus <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'core/mouse.zig')
| -rw-r--r-- | core/mouse.zig | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/core/mouse.zig b/core/mouse.zig index 3d7c5af9..8d0aebc8 100644 --- a/core/mouse.zig +++ b/core/mouse.zig @@ -247,8 +247,11 @@ fn kindMouse(p: *Pardes, m: Mouse) bool { if (m.kind == .press) v.active = id; if (m.kind == .press and m.button != .wheel_up and m.button != .wheel_down and m.button != .wheel_left and m.button != .wheel_right) v.kind_grab = @intCast(id); if (m.kind == .release) v.kind_grab = null; - const col = std.math.clamp(m.col, x0, r.x + r.w -| 1) - x0; - const row = std.math.clamp(m.row, top, r.y + r.h -| 1) - top; + // Grabbed, it may be anywhere, and the pane since made too narrow + // or short for a cell of body (a resize, a pane added above): its + // body's last cell, the first of none. + const col = @min(m.col -| x0, (r.x + r.w) -| x0 -| 1); + const row = @min(m.row -| top, (r.y + r.h) -| top -| 1); return pardes.Kind.mouse(p, id, m, col, row); } kindLeave(p); |
