diff options
Diffstat (limited to 'src/ninep/ctl.zig')
| -rw-r--r-- | src/ninep/ctl.zig | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig index 269e9346..028ddf55 100644 --- a/src/ninep/ctl.zig +++ b/src/ninep/ctl.zig @@ -1809,6 +1809,25 @@ test "Get reads the pane's file again, refusing unsaved edits once, and Get file try testing.expect(!pane_files.dirtyOf(pane)); } +test "Putall saves every pane with unsaved edits to a file, one each, and leaves the rest" { + const p = try withFile(testing.allocator, "x\n"); + defer p.deinit(); + const first = serialOf(p); + _ = wr(p, Node.of(first, .name), "/tmp/pardes-putall-a.txt\n"); + _ = wr(p, Node.of(first, .body), "edited\n"); + const second = p.freeSlot().?; + _ = try p.newDocPane(second); + p.panes[second].?.file = .{ .path = try p.gpa.dupe(u8, "/tmp/pardes-putall-b.txt"), .content = try p.gpa.dupe(u8, "clean\n"), .history = try panes.File.History.create(p.gpa) }; + while (p.nextEffect()) |_| {} + try testing.expect(p.executeBuiltinLine(0, "Putall")); + var saves: usize = 0; + while (p.nextEffect()) |e| if (e == .save_file) { + saves += 1; + try testing.expectEqual(@as(u16, 0), e.save_file.pane); + }; + try testing.expectEqual(@as(usize, 1), saves); +} + test "a body write to a terminal is typed input, not a paste, even to a program that asked for bracketed paste" { const p = try Pardes.init(testing.allocator, .{ .cols = 90, .rows = 30 }); defer p.deinit(); @@ -3191,7 +3210,7 @@ test "acme's words run as pardes's (Put is Save, Delete a Del that does not ask) const p = try withFile(testing.allocator, "x\n"); defer p.deinit(); const serial = serialOf(p); - for ([_][]const u8{ "Snarf\n", "Putall\n", "Zerox\n", "Tab\n", "Indent\n", "Local\n", "Incl\n", "Abort\n" }) |line| { + for ([_][]const u8{ "Snarf\n", "Zerox\n", "Tab\n", "Indent\n", "Local\n", "Incl\n", "Abort\n" }) |line| { for ([_]u64{ Node.of(serial, .ctl), Node.of(serial, .exec) }) |node| { const r = wr(p, node, line); try testing.expectEqual(E.INVAL, r.errno()); |
