772dbdd6
Fix selection clear on off-grid click and clampGridPoint row clamping
a73x 2026-04-09 18:47
- Left-click outside the grid now always clears committed selection (previously only cleared when hover was non-null, leaving stale committed selections behind on off-grid clicks) - clampGridPoint now clamps row to max_row instead of returning null, matching the existing col-clamping behaviour; avoids silently losing anchor during mid-drag grid resize Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
diff --git a/src/main.zig b/src/main.zig index 94fafe6..ed72de0 100644 --- a/src/main.zig +++ b/src/main.zig @@ -689,10 +689,9 @@ fn clampGridPoint(point: GridPoint, cols: u16, rows: u16) ?GridPoint { if (cols == 0 or rows == 0) return null; const max_col = @as(u32, cols) - 1; const max_row = @as(u32, rows) - 1; if (point.row > max_row) return null; return .{ .col = @min(point.col, max_col), .row = point.row, .row = @min(point.row, max_row), }; } @@ -731,10 +730,10 @@ fn handlePointerSelectionEvent( }, .button_press => |b| { if (b.button == BTN_LEFT) { state.committed = null; if (state.hover) |hover| { state.anchor = hover; state.active = .{ .start = hover, .end = hover }; state.committed = null; } } },