a73x

772dbdd6

Fix selection clear on off-grid click and clampGridPoint row clamping

a73x   2026-04-09 18:47

Commit message
Fix selection clear on off-grid click and clampGridPoint row clamping

- 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>

src/main.zig
Old New
@@ -689,10 +689,9 @@ fn clampGridPoint(point: GridPoint, cols: u16, rows: u16) ?GridPoint {
689 if (cols == 0 or rows == 0) return null; 689 if (cols == 0 or rows == 0) return null;
690 const max_col = @as(u32, cols) - 1; 690 const max_col = @as(u32, cols) - 1;
691 const max_row = @as(u32, rows) - 1; 691 const max_row = @as(u32, rows) - 1;
692 if (point.row > max_row) return null;
693 return .{ 692 return .{
694 .col = @min(point.col, max_col), 693 .col = @min(point.col, max_col),
695 .row = point.row, 694 .row = @min(point.row, max_row),
696 }; 695 };
697 } 696 }
698 697
@@ -731,10 +730,10 @@ fn handlePointerSelectionEvent(
731 }, 730 },
732 .button_press => |b| { 731 .button_press => |b| {
733 if (b.button == BTN_LEFT) { 732 if (b.button == BTN_LEFT) {
733 state.committed = null;
734 if (state.hover) |hover| { 734 if (state.hover) |hover| {
735 state.anchor = hover; 735 state.anchor = hover;
736 state.active = .{ .start = hover, .end = hover }; 736 state.active = .{ .start = hover, .end = hover };
737 state.committed = null;
738 } 737 }
739 } 738 }
740 }, 739 },