diff options
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 |
