diff options
| author | Gabriel Schneider <[email protected]> | 2026-09-29 05:30:54 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-10-01 00:12:16 -0300 |
| commit | 2fe2c920513fc78b61039714bf4d11ae48169f40 (patch) | |
| tree | 5edb4c35faa895c9b6d5d9a525d2085fbb3173dc /src/builtins.zig | |
| parent | 24729dbbf8b32966a3f33c9bc20599b185856dd3 (diff) | |
| download | pardes-2fe2c920513fc78b61039714bf4d11ae48169f40.tar.gz pardes-2fe2c920513fc78b61039714bf4d11ae48169f40.zip | |
An Edit block cut short through exec is an err, not a msg
An exec write does not fail for what its command says, so an a/c/i text
or { group cut short by a write that ended early was only a msg, easy to
miss. Over 9P, that failure (a truncated write, not a command's) is now
logged as an err record naming exec; the pane still says it.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/builtins.zig')
| -rw-r--r-- | src/builtins.zig | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/builtins.zig b/src/builtins.zig index dfd1e84c..6ca216e3 100644 --- a/src/builtins.zig +++ b/src/builtins.zig @@ -946,7 +946,21 @@ pub const Edit = struct { var why: sam.Why = .{}; var said: [260]u8 = undefined; const res = sam.run(arena, f.content, ninep_pane.dotOf(c.pane), f.path, c.arg orelse "", &why) catch |err| switch (err) { - error.Edit => return c.p.reportFailure(c.id, std.fmt.bufPrint(&said, "Edit: {s}", .{why.text()}) catch "Edit: failed"), + error.Edit => { + const text = std.fmt.bufPrint(&said, "Edit: {s}", .{why.text()}) catch "Edit: failed"; + // A block cut short (no `.` line, no `}`) that came over + // 9P through an exec, whose write does not fail for what + // a command says, is still the write's fault: an err. + const cut = std.mem.eql(u8, why.text(), "unmatched `{'") or std.mem.startsWith(u8, why.text(), "a, c or i text not ended"); + if (cut and c.p.fs.serving and !c.p.fs.no_prompt) { + var rec: [300]u8 = undefined; + pardes.ctlfs.events.notePath(c.p, "err", std.fmt.bufPrint(&rec, "{d} exec: {s}", .{ c.pane.serial, text }) catch "- exec: Edit failed"); + c.p.fs.unlogged = true; + defer c.p.fs.unlogged = false; + return c.p.reportFailure(c.id, text); + } + return c.p.reportFailure(c.id, text); + }, error.OutOfMemory => return c.p.reportError(c.id, "Edit", err), }; if (res.undo != 0) { |
