summaryrefslogtreecommitdiff
path: root/src/builtins.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/builtins.zig')
-rw-r--r--src/builtins.zig20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/builtins.zig b/src/builtins.zig
index 4490482d..3e35ca2f 100644
--- a/src/builtins.zig
+++ b/src/builtins.zig
@@ -463,7 +463,7 @@ fn warnModifiedIn(c: Ctx, asking: Pane.Discarding, which: Asked) bool {
var modified = false;
// Every pane asked about is named in the one refusal a ctl write gets,
// as acme's rowclean names them all (wind.c:511).
- var all_buf: [256]u8 = undefined;
+ var all_buf: [1024]u8 = undefined;
var all = std.Io.Writer.fixed(&all_buf);
for (c.p.panes, 0..) |slot, id| {
const pane = slot orelse continue;
@@ -486,9 +486,14 @@ fn warnModifiedIn(c: Ctx, asking: Pane.Discarding, which: Asked) bool {
if (std.hash.Wyhash.hash(0, f.content) == saved) continue;
if (pane.discard_warned) |w| if (w.revision == f.revision and w.by == asking) continue;
pane.discard_warned = .{ .revision = f.revision, .by = asking };
- var buf: [limits.host_path_cap + 48]u8 = undefined;
- c.p.reportFailure(id, std.fmt.bufPrint(&buf, "{s}: Modified ({s} again to discard)", .{ f.path, @tagName(asking) }) catch f.path);
- all.print("{s}{s}", .{ if (modified) ", " else "", f.path }) catch {};
+ // Scratches share a name: each is named with its pane's serial too,
+ // `/dir/+New (pane 12)`, the same in every refusal (Exit, Restore,
+ // Del, Delcol).
+ var name_buf: [limits.host_path_cap + 24]u8 = undefined;
+ const name = if (scratch) std.fmt.bufPrint(&name_buf, "{s} (pane {d})", .{ f.path, pane.serial }) catch f.path else f.path;
+ var buf: [limits.host_path_cap + 72]u8 = undefined;
+ c.p.reportFailure(id, std.fmt.bufPrint(&buf, "{s}: Modified ({s} again to discard)", .{ name, @tagName(asking) }) catch name);
+ all.print("{s}{s}", .{ if (modified) ", " else "", name }) catch {};
modified = true;
}
if (modified and c.p.fs.no_prompt) {
@@ -1806,7 +1811,12 @@ test "Exit and Restore name a modified +New scratch as well as files" {
try std.testing.expect(!p.quit);
const said = p.fs.failure[0..p.fs.failure_len];
try std.testing.expect(std.mem.indexOf(u8, said, "test.txt") != null);
- try std.testing.expect(std.mem.indexOf(u8, said, config.scratch_buffer) != null);
+ var named: [64]u8 = undefined;
+ try std.testing.expect(std.mem.indexOf(u8, said, try std.fmt.bufPrint(&named, "{s} (pane {d})", .{ config.scratch_buffer, p.panes[p.active].?.serial })) != null);
+ // Delcol, Restore and Exit name it the same way.
+ p.fs.failure_len = 0;
+ try std.testing.expect(p.executeBuiltinLine(p.active, "Delcol"));
+ try std.testing.expect(std.mem.indexOf(u8, p.fs.failure[0..p.fs.failure_len], named[0 .. config.scratch_buffer.len + 7]) != null);
}
test "Del and Delcol refuse a pane with unsaved text once, as acme's do, and close on the second" {