From 137adecd03be209901efb228d9288282bc36c8de Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 29 Sep 2026 12:42:20 -0300 Subject: +Unsaved drops a pane once it has closed The list kept a pane's Modified row after the pane was closed (discarded), so it named text there was no longer anything to lose of. A pane's closing now takes its row out. Co-Authored-By: Claude Opus 5.5 --- src/ninep/ctl.zig | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src/ninep') diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig index 0d3f084d..3d7ee91a 100644 --- a/src/ninep/ctl.zig +++ b/src/ninep/ctl.zig @@ -2176,6 +2176,31 @@ test "Grep, Symbols and Diagnostics share their directory's one +Search" { try testing.expectEqual(@as(usize, 1), searches); } +test "+Unsaved drops a pane once it has closed" { + const p = try withFile(testing.allocator, "x\n"); + defer p.deinit(); + const a = try th.newPane(p); + _ = wr(p, Node.of(a, .name), "/tmp/pardes-unsaved-a.txt\n"); + _ = wr(p, Node.of(a, .body), "edited\n"); + const b = try th.newPane(p); + _ = wr(p, Node.of(b, .name), "/tmp/pardes-unsaved-b.txt\n"); + _ = wr(p, Node.of(b, .body), "edited\n"); + const root_ctl = @intFromEnum(tree.TopFile.ctl); + try testing.expectEqual(Status.err, wr(p, root_ctl, "Exit\n").reply.status); + var listed: ?*pardes.Pane = null; + for (p.panes) |slot| if (slot) |q| if (q.file) |f| if (f.output) |o| if (o.from == .unsaved) { + listed = q; + }; + const list = listed.?; + try testing.expect(std.mem.indexOf(u8, list.file.?.content, "/tmp/pardes-unsaved-a.txt: Modified") != null); + // a closes (discarded): its row goes; b's stays. + _ = wr(p, Node.of(a, .ctl), "Del\n"); + _ = wr(p, Node.of(a, .ctl), "Del\n"); + p.sync(); + try testing.expect(p.paneBySerial(a) == null); + try testing.expect(std.mem.indexOf(u8, list.file.?.content, "/tmp/pardes-unsaved-a.txt: Modified") == null); +} + test "every EINVAL a write gets says why, in its err record too; DEL is a control character in a line" { const p = try withFile(testing.allocator, "x\n"); defer p.deinit(); -- cgit v1.3