summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ninep/ctl.zig26
-rw-r--r--src/pardes.zig8
2 files changed, 34 insertions, 0 deletions
diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig
index 3d7ee91a..b93d83c3 100644
--- a/src/ninep/ctl.zig
+++ b/src/ninep/ctl.zig
@@ -2348,6 +2348,32 @@ test "a column takes panes until their documented minimums fill it, not until no
}
}
+test "a Jumplist entry is (closed) only while no pane has its file open" {
+ 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 = "a.txt", .data = "one\n" });
+ try tmp.dir.writeFile(testing.io, .{ .sub_path = "b.txt", .data = "two\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;
+ _ = wr(p, root_look, try std.fmt.bufPrint(&line, "{s}/a.txt\n", .{dir}));
+ p.sync();
+ const a = p.panes[p.active].?.serial;
+ _ = wr(p, root_look, try std.fmt.bufPrint(&line, "{s}/b.txt\n", .{dir}));
+ p.sync();
+ _ = wr(p, Node.of(a, .ctl), "Del\n");
+ p.sync();
+ var closed: usize = 0;
+ for (p.jumps[0..p.njumps]) |j| closed += @intFromBool(j.serial == 0);
+ try testing.expect(closed > 0);
+ // Open again, by a look: no entry is closed any more.
+ _ = wr(p, root_look, try std.fmt.bufPrint(&line, "{s}/a.txt\n", .{dir}));
+ p.sync();
+ for (p.jumps[0..p.njumps]) |j| try testing.expect(j.serial != 0);
+}
+
test "a closed file is found again: Recent and /recent list it closed, a look at its row reopens it at its dot, and a jump back does too" {
const p = try withFile(testing.allocator, "x\n");
defer p.deinit();
diff --git a/src/pardes.zig b/src/pardes.zig
index 2649014a..1f136f2b 100644
--- a/src/pardes.zig
+++ b/src/pardes.zig
@@ -6806,6 +6806,14 @@ pub const Pardes = struct {
if (!live) {
if (j.path_hash == 0 or p.recentByHash(j.path_hash) == null) continue;
kept.serial = 0;
+ // Open again in some pane (a look, Recent): the entry is that
+ // pane's, and closed only while no pane has the file.
+ for (p.panes, 0..) |slot, id| if (slot) |pane| if (recentDot(pane)) |d| {
+ if (std.hash.Wyhash.hash(0, d.path) != j.path_hash) continue;
+ kept.pane = @intCast(id);
+ kept.serial = pane.serial;
+ break;
+ };
}
p.jumps[w] = kept;
w += 1;