summaryrefslogtreecommitdiff
path: root/src/ninep
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-09-29 13:59:02 -0300
committerGabriel Schneider <[email protected]>2026-10-01 00:12:16 -0300
commit379bb906ad3f40937cffa994b6e3550e43f5491a (patch)
tree300261becff3ff81f388dff6ceb5c3ae8bf64b15 /src/ninep
parentbb770b12a4ab9ef7dbeee9ade5a1e51e90b4d15b (diff)
downloadpardes-379bb906ad3f40937cffa994b6e3550e43f5491a.tar.gz
pardes-379bb906ad3f40937cffa994b6e3550e43f5491a.zip
A new file, once saved, shows in /recent, open
A pane named for a file not yet on disk is not kept in Recent (round 22), and its Save did not add it, so the file stayed out of /recent while open. A Save that puts a file on disk now records it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/ninep')
-rw-r--r--src/ninep/ctl.zig27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig
index a11bfeda..e31b9e67 100644
--- a/src/ninep/ctl.zig
+++ b/src/ninep/ctl.zig
@@ -2543,6 +2543,33 @@ test "Recent keeps only files on disk: not a name never saved, nor the served tr
try testing.expect(p.recent.get(names[2]) != null);
}
+test "a new file saved shows in /recent, open, while it is" {
+ const p = try withFile(testing.allocator, "x\n");
+ defer p.deinit();
+ var tmp = testing.tmpDir(.{});
+ defer tmp.cleanup();
+ var dir_buf: [4096]u8 = undefined;
+ const dir = dir_buf[0..try tmp.dir.realPath(testing.io, &dir_buf)];
+ // A host that writes files, as the real ones do.
+ const Writing = struct {
+ fn write(_: ?*anyopaque, _: u8, path: []const u8, bytes: []const u8) void {
+ std.Io.Dir.cwd().writeFile(testing.io, .{ .sub_path = path, .data = bytes }) catch {};
+ }
+ };
+ p.host = .{ .vtable = &.{ .write_file = Writing.write } };
+ defer p.host = .{};
+ const made = try th.newPane(p);
+ var line: [4200]u8 = undefined;
+ const path = try std.fmt.bufPrint(&line, "{s}/new.txt", .{dir});
+ var name: [4200]u8 = undefined;
+ _ = wr(p, Node.of(made, .name), try std.fmt.bufPrint(&name, "{s}\n", .{path}));
+ _ = wr(p, Node.of(made, .body), "fresh\n");
+ try testing.expectEqual(Status.ok, wr(p, Node.of(made, .ctl), "Save\n").reply.status);
+ p.perform(.{ .save_file = .{ .pane = @intCast(p.paneBySerial(made).?) } });
+ var want: [4300]u8 = undefined;
+ try testing.expect(std.mem.indexOf(u8, rd(p, @intFromEnum(tree.TopFile.recent), 0, 8192).bytes, try std.fmt.bufPrint(&want, "open {s}\n", .{path})) != 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();