summaryrefslogtreecommitdiff
path: root/src/ninep
diff options
context:
space:
mode:
Diffstat (limited to 'src/ninep')
-rw-r--r--src/ninep/ctl.zig28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig
index d815632d..db058ff2 100644
--- a/src/ninep/ctl.zig
+++ b/src/ninep/ctl.zig
@@ -2408,6 +2408,34 @@ test "/recent shows a name as /index does, a newline in it escaped" {
try testing.expect(std.mem.indexOf(u8, text, "closed /tmp/a\\nb\\\\c\n") != null);
}
+test "Back over a closed file deleted since skips it, says so, and goes on to the place before" {
+ const p = try withFile(testing.allocator, "x\n");
+ defer p.deinit();
+ var tmp = testing.tmpDir(.{});
+ defer tmp.cleanup();
+ for ([_][]const u8{ "a.txt", "gone.txt", "c.txt" }) |name| try tmp.dir.writeFile(testing.io, .{ .sub_path = name, .data = "text\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_serial = p.panes[p.active].?.serial;
+ _ = wr(p, root_look, try std.fmt.bufPrint(&line, "{s}/gone.txt\n", .{dir}));
+ p.sync();
+ const gone = p.active;
+ _ = wr(p, root_look, try std.fmt.bufPrint(&line, "{s}/c.txt\n", .{dir}));
+ p.sync();
+ const c_id = p.active;
+ _ = wr(p, Node.of(p.panes[gone].?.serial, .ctl), "Del\n");
+ p.sync();
+ try tmp.dir.deleteFile(testing.io, "gone.txt");
+ p.active = c_id;
+ p.jumpBy(-1);
+ p.sync();
+ try testing.expectEqual(a_serial, p.panes[p.active].?.serial);
+ try testing.expect(std.mem.indexOf(u8, p.panes[c_id].?.msg[0..p.panes[c_id].?.msg_len], "gone.txt: deleted, skipped") != null);
+}
+
test "a remembered place is clamped to the file as it is now, its selection's two ends kept where they fit" {
const p = try withFile(testing.allocator, "x\n");
defer p.deinit();