From ffa2fd2d4b40bc4ff2a05263cf82ee9638590edd Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 15 Sep 2026 20:15:48 -0300 Subject: Keep unavailable numeric Look targets harmless when clearing selection --- src/pardes.zig | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'src/pardes.zig') diff --git a/src/pardes.zig b/src/pardes.zig index 8bccfd89..2a8ae5cc 100644 --- a/src/pardes.zig +++ b/src/pardes.zig @@ -12388,7 +12388,9 @@ pub const Pardes = struct { } }, .pane => |t| { - p.clearLookSelection(p.panes[t.id].?); + if (t.id >= MAX_PANES) return; + const target = p.panes[t.id] orelse return; + p.clearLookSelection(target); p.focusPaneLine(t.id, t.at, .center); }, .url => |u| if (u.len <= 256) p.emit(.{ .open_link = .from(u) }), @@ -14985,6 +14987,19 @@ test "Look copies its operand before releasing pointer selection storage" { try std.testing.expectEqual(.none, p.drag); } +test "Look ignores missing and out of bounds pane addresses" { + const p = try Pardes.init(std.testing.allocator, .{ .cols = 60, .rows = 12 }); + defer p.deinit(); + const pane = try p.setTestFile("alpha\nbravo\n"); + for ([_][]const u8{ config.pane_addr ++ "15:2", config.pane_addr ++ "999999:2" }) |operand| { + pane.setRange(pane.file.?.content, 0, .{ .anchor = 0, .head = 3 }, true); + p.lookAt(0, operand); + try std.testing.expectEqual(@as(usize, 0), p.active); + try std.testing.expectEqual(@as(i32, 0), pane.cur_row); + try std.testing.expect(!pane.vsel.active); + } +} + test "jump history preserves modal and mouse selections" { const p = try Pardes.init(std.testing.allocator, .{ .cols = 60, .rows = 12 }); defer p.deinit(); -- cgit v1.3