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.zig24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig
index f4a3d730..dc2d9a84 100644
--- a/src/ninep/ctl.zig
+++ b/src/ninep/ctl.zig
@@ -2304,6 +2304,30 @@ test "Back and Forward over a closed file's entries: one reopen is that file's p
try testing.expectEqual(c_serial, p.panes[p.active].?.serial);
}
+test "Recent keeps only files on disk: not a name never saved, nor the served tree's" {
+ const p = try withFile(testing.allocator, "x\n");
+ defer p.deinit();
+ var tmp = testing.tmpDir(.{});
+ defer tmp.cleanup();
+ try tmp.dir.writeFile(testing.io, .{ .sub_path = "real.txt", .data = "real\n" });
+ var dir_buf: [4096]u8 = undefined;
+ const dir = dir_buf[0..try tmp.dir.realPath(testing.io, &dir_buf)];
+ var line: [4200]u8 = undefined;
+ const names = [_][]const u8{ try std.fmt.allocPrint(testing.allocator, "{s}/c", .{dir}), try testing.allocator.dupe(u8, "/virtual/zz"), try std.fmt.allocPrint(testing.allocator, "{s}/real.txt", .{dir}) };
+ defer for (names) |n| testing.allocator.free(n);
+ for (names) |name| {
+ const made = try th.newPane(p);
+ _ = wr(p, Node.of(made, .name), try std.fmt.bufPrint(&line, "{s}\n", .{name}));
+ p.sync();
+ _ = wr(p, Node.of(made, .ctl), "Del\n");
+ _ = wr(p, Node.of(made, .ctl), "Del\n");
+ p.sync();
+ }
+ try testing.expect(p.recent.get(names[0]) == null);
+ try testing.expect(p.recent.get(names[1]) == null);
+ try testing.expect(p.recent.get(names[2]) != null);
+}
+
test "/recent shows a name as /index does, a newline in it escaped" {
const p = try withFile(testing.allocator, "x\n");
defer p.deinit();