summaryrefslogtreecommitdiff
path: root/src/ninep
diff options
context:
space:
mode:
Diffstat (limited to 'src/ninep')
-rw-r--r--src/ninep/ctl.zig24
-rw-r--r--src/ninep/events.zig2
-rw-r--r--src/ninep/pane.zig2
3 files changed, 26 insertions, 2 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();
diff --git a/src/ninep/events.zig b/src/ninep/events.zig
index 2fe25071..add0d750 100644
--- a/src/ninep/events.zig
+++ b/src/ninep/events.zig
@@ -141,7 +141,7 @@ pub fn announce(p: *Pardes) void {
pane.fs.unannounced = false;
noteLog(p, .new, pane);
// A file opened (a look, a Restore, a boot): first in Recent.
- if (pane.file) |f| if (f.output == null) p.recent.opened(p.recentGpa(), f.path);
+ if (pane.file) |f| if (f.output == null and pardes.Pardes.recentKeeps(f.path)) p.recent.opened(p.recentGpa(), f.path);
}
}
diff --git a/src/ninep/pane.zig b/src/ninep/pane.zig
index 0b6f04a4..5ed3f6f4 100644
--- a/src/ninep/pane.zig
+++ b/src/ninep/pane.zig
@@ -687,7 +687,7 @@ pub fn nameBuffer(p: *Pardes, id: usize, full: []const u8, preserve_tag: bool) !
look.invalidateLookHover(p, id);
p.emit(.{ .watch = .{ .pane = @intCast(id), .on = false } });
events.noteLog(p, .rename, pane);
- if (f.output == null) p.recent.opened(p.recentGpa(), f.path);
+ if (f.output == null and pardes.Pardes.recentKeeps(f.path)) p.recent.opened(p.recentGpa(), f.path);
}
/// Diagnostics go to the +Errors buffer of the pane's directory.