summaryrefslogtreecommitdiff
path: root/src/normal.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-09-28 01:09:05 -0300
committerGabriel Schneider <[email protected]>2026-10-01 00:12:14 -0300
commitf48ab559a4d257137a3aae987a4962f9d74ede23 (patch)
tree99b233f7386673ee7a84031f4e5ff1b3011adae0 /src/normal.zig
parentfb72c2402fa1b1ae99be64fe7b2947ea5dd42623 (diff)
downloadpardes-f48ab559a4d257137a3aae987a4962f9d74ede23.tar.gz
pardes-f48ab559a4d257137a3aae987a4962f9d74ede23.zip
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 <[email protected]>
Diffstat (limited to 'src/normal.zig')
-rw-r--r--src/normal.zig4
1 files changed, 2 insertions, 2 deletions
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 })) {