From 84c8209d02f6830db861c3a8dde0c710c88075f0 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Mon, 9 Nov 2026 03:29:30 -0300 Subject: idioms: the edit surface fails by name: the undo history (Journal.mark, Text.remember and step, File's, terminal's and edit's pushUndo and undoStep) returns error{OutOfMemory} instead of dropping an undo point, setEditText, enterInsert and insertTab return edit.Error with try where they reported each failure, Registers.put and setYank return error{OutOfMemory} instead of losing a yank, and their other-file callers decide (try under edit.Error, said on the pane by Undo, Redo, Pipe, Edit, Query, keys, look, completion, Incl and Plumb, ENOMEM or null where a 9P write answers, Ask's false); ctl.get and getFile return GetError (fs.ReadError, now named at fs.zig's surface, and InvalidName) for the *anyerror out-parameter and errno, the 9P get, Get and Edit's e mapping it as before; the OOM undo test pins the error; perf.zig's try relabels its harness hash, the three baselines re-keyed to it (their numbers the base's) Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge --- src/edit_cmd.zig | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/edit_cmd.zig') diff --git a/src/edit_cmd.zig b/src/edit_cmd.zig index b1239a84..f299a39d 100644 --- a/src/edit_cmd.zig +++ b/src/edit_cmd.zig @@ -198,7 +198,7 @@ pub fn run(p: *Pardes, id: usize, command: []const u8) void { } } if (res.undo != 0) { - for (0..@abs(res.undo)) |_| panes.File.undoStep(p, pane, res.undo > 0); + for (0..@abs(res.undo)) |_| panes.File.undoStep(p, pane, res.undo > 0) catch |err| return p.reportError(id, "Edit", err); return; } pd.res = res; @@ -357,9 +357,8 @@ fn commit(p: *Pardes, pd: *Pending, outputs: []const []const u8) void { // back with the old text, and it leaves the pane clean. for (res.files) |f| { const path = f.get orelse continue; - var failed: anyerror = error.Unexpected; - const errno = @import("ninep/ctl.zig").getFile(p, p.panes[f.id].?, path, &failed); - if (errno != 0) return p.reportFailure(at, text.print("Edit: e {s}: {s}", .{ path[0..@min(path.len, 256)], if (errno == @import("ninep/tree.zig").E.NOENT) "no such file" else "cannot be read" })); + @import("ninep/ctl.zig").getFile(p, p.panes[f.id].?, path) catch |err| + return p.reportFailure(at, text.print("Edit: e {s}: {s}", .{ path[0..@min(path.len, 256)], if (err == error.FileNotFound) "no such file" else "cannot be read" })); } // `w`'s bytes, written after this step, before anything else is. To // its own file changed on disk since it was read, as Save is: refused @@ -410,7 +409,10 @@ fn commit(p: *Pardes, pd: *Pending, outputs: []const []const u8) void { const new = sam.apply(p.gpa, pf.content, ops) catch |err| return p.reportError(at, "Edit", err); // `s/a/a/` changes nothing: no undo step, no new revision. if (std.mem.eql(u8, new, pf.content)) p.gpa.free(new) else { - panes.File.pushUndo(p, pane); + panes.File.pushUndo(p, pane) catch |err| { + p.gpa.free(new); + return p.reportError(at, "Edit", err); + }; panes.File.setContent(p, pf, new); } } -- cgit v1.3