From f48ab559a4d257137a3aae987a4962f9d74ede23 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Mon, 28 Sep 2026 01:09:05 -0300 Subject: Have Text.pane return nothing for a header instead of trapping A column's or the workspace's tag has no pane, and asking one for it hit unreachable; every caller guarded against that by checking `what` first. An optional makes each caller say what it does without a pane, so a forgotten guard no longer compiles into a crash. Co-Authored-By: Claude Opus 5.5 --- src/normal.zig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/normal.zig') diff --git a/src/normal.zig b/src/normal.zig index 29d6d620..c7e75d70 100644 --- a/src/normal.zig +++ b/src/normal.zig @@ -175,7 +175,7 @@ const Replay = union(enum) { pub fn replaySels(p: *Pardes, t: *Text, what: Replay) void { const id = p.active; // a header belongs to no pane and cannot go away under the replay - const owner: ?*Pane = if (t.what == .column or t.what == .workspace) null else t.pane(); + const owner = t.pane(); const serial = if (owner) |pane| pane.serial else 0; // the whole selection in text coordinates, document order. t.sels // is already ordered, so this only slots the primary into place. @@ -292,7 +292,7 @@ pub fn handleNormal(p: *Pardes, t: *Text, key: Key) void { fn executeNormalAction(p: *Pardes, t: *Text, semantic: modal.Normal.Action) void { // What reaches past the text -- a builtin, a search, a language query -- // acts for the pane the text belongs to; a header's is the active one. - const pane = if (t.what == .column or t.what == .workspace) p.panes[p.active] orelse return else t.pane(); + const pane = t.pane() orelse p.panes[p.active] orelse return; const raw_selection = t.what == .body and pane.rawPointerText(pane.sel[sel_slot]) != null; const before = .{ t.cur_row, t.cur_col, t.vsel, t.msel, t.select, t.nsel, t.mode }; defer if (raw_selection and !std.meta.eql(before, .{ t.cur_row, t.cur_col, t.vsel, t.msel, t.select, t.nsel, t.mode })) { -- cgit v1.3