summaryrefslogtreecommitdiff
path: root/src/ninep/ctl.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/ninep/ctl.zig')
-rw-r--r--src/ninep/ctl.zig25
1 files changed, 25 insertions, 0 deletions
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();