diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-06 13:16:39 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-06 14:56:36 -0300 |
| commit | 961bea06443e25a92e02be58136065c2a1ea84c1 (patch) | |
| tree | 983433b6ec9b5855530e187ccc2e8a783b8fd42e /src/edit_cmd.zig | |
| parent | 80f4398f1fed8d46d73cab8045005c02189b34fc (diff) | |
| download | pardes-961bea06443e25a92e02be58136065c2a1ea84c1.tar.gz pardes-961bea06443e25a92e02be58136065c2a1ea84c1.zip | |
idioms #15, the catch unreachable sites slice b added, re-classified: 29 that a word, a path, an id or a function's text could reach go back to a cut through Kind.Buf (or, at echoCommand's and Repl's writers, a failure handled once at the writer), 95 stay because every argument is an integer, a literal, a comptime word or a cut in the same statement (one added to Ask's arg, ctl's why, choices, word and the ids and fields paneText writes, events' records and Edit's names), each with its reason on its line
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'src/edit_cmd.zig')
| -rw-r--r-- | src/edit_cmd.zig | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/edit_cmd.zig b/src/edit_cmd.zig index 1a99e76c..0f10e136 100644 --- a/src/edit_cmd.zig +++ b/src/edit_cmd.zig @@ -178,7 +178,7 @@ pub fn run(p: *Pardes, id: usize, command: []const u8) void { var why: sam.Why = .{}; var text: [260]u8 = undefined; const res = sam.run(arena, files.items, cur, command, .{ .ctx = &world, .check = World.check, .open = World.open, .read = World.read, .refuseGet = World.refuseGet }, &why) catch |err| switch (err) { - error.Edit => return p.reportFailure(id, std.fmt.bufPrint(&text, "Edit: {s}", .{why.text()}) catch unreachable), // why's 200 fit 260 + error.Edit => return p.reportFailure(id, std.fmt.bufPrint(&text, "Edit: {s}", .{why.text()}) catch unreachable), // why.text() is a slice of Why's [200]u8 buf; 6 more fit 260 error.OutOfMemory => return p.reportError(id, "Edit", err), }; // acme's Edit blocks the editor while its commands run; here the editor @@ -347,12 +347,10 @@ fn commit(p: *Pardes, pd: *Pending, outputs: []const []const u8) void { var text: [320]u8 = undefined; for (res.files, 0..) |f, i| { if (f.ops.items.len == 0 and !f.close and !f.renamed and !f.moved and f.get == null) continue; - // unreachable: 256 of the name and 56 fit 320. - const name = f.name[0..@min(f.name.len, 256)]; - const pane = p.panes[f.id] orelse return p.reportFailure(at, std.fmt.bufPrint(&text, "Edit: {s} closed while its commands ran; nothing changed", .{name}) catch unreachable); - if (pane.serial != pd.serials[i]) return p.reportFailure(at, std.fmt.bufPrint(&text, "Edit: {s} closed while its commands ran; nothing changed", .{name}) catch unreachable); + const pane = p.panes[f.id] orelse return p.reportFailure(at, std.fmt.bufPrint(&text, "Edit: {s} closed while its commands ran; nothing changed", .{f.name[0..@min(f.name.len, 256)]}) catch unreachable); // 256 and 56 fit 320 + if (pane.serial != pd.serials[i]) return p.reportFailure(at, std.fmt.bufPrint(&text, "Edit: {s} closed while its commands ran; nothing changed", .{f.name[0..@min(f.name.len, 256)]}) catch unreachable); // 256 and 56 fit 320 if ((f.ops.items.len > 0 or f.get != null) and pane.file.?.revision != pd.revisions[i]) - return p.reportFailure(at, std.fmt.bufPrint(&text, "Edit: {s} changed while its commands ran; nothing changed", .{name}) catch unreachable); + return p.reportFailure(at, std.fmt.bufPrint(&text, "Edit: {s} changed while its commands ran; nothing changed", .{f.name[0..@min(f.name.len, 256)]}) catch unreachable); // 256 and 57 fit 320 } // e first, Get's way: read before anything is changed, so one that // cannot be read changes nothing; its own undo step puts the old name |
