From 109a558a0488f3269f1864985e9b3db5f58b9552 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Wed, 30 Sep 2026 19:23:38 -0300 Subject: A builtin for one kind of pane is refused on another with why: Petscii, Palette, Ascii, Filter, Togglettymode, the Pdf words, Mode and TreeContext Each of these did nothing, silently, on the wrong kind of pane, so a ctl or exec write of Palette to a text file answered ok as if it had acted. A builtin now declares the one kind it is for (needs), the registry reads it, and runBuiltinFrom refuses the rest before dispatch, as Repl and Edit already refused theirs. Mode and TreeContext, which take more than one kind, say their own refusal. Co-Authored-By: Claude Opus 5.5 --- src/exec.zig | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/exec.zig') diff --git a/src/exec.zig b/src/exec.zig index 5a421f19..215a4fd1 100644 --- a/src/exec.zig +++ b/src/exec.zig @@ -959,6 +959,12 @@ pub fn runBuiltinFrom(p: *Pardes, b: Builtin, id: usize, txt: []const u8, arg: ? p.fs.unlogged = false; pane.msg_announcement = true; } + // A word for one kind of pane, on another: refused with why, not a + // silent nothing (Palette on a file, Filter on a PDF). + if (builtins.registry.needs(b)) |kind| if (p.panes[id] == null or !kind.has(pane)) { + var said: [96]u8 = undefined; + return p.reportFailure(id, std.fmt.bufPrint(&said, "{s}: only {s} pane takes it", .{ @tagName(b), kind.noun() }) catch "only another kind of pane takes it"); + }; const c: builtins.Ctx = .{ .p = p, .pane = pane, .id = id, .txt = txt, .arg = arg, .from_body = from_body }; builtins.registry.dispatch(b, c); } -- cgit v1.3