diff options
Diffstat (limited to 'test/behaviour/other_files.zig')
| -rw-r--r-- | test/behaviour/other_files.zig | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/test/behaviour/other_files.zig b/test/behaviour/other_files.zig index 701f4f14..ae4c2928 100644 --- a/test/behaviour/other_files.zig +++ b/test/behaviour/other_files.zig @@ -191,6 +191,33 @@ test "other-files: a closed file is found again: Recent and /recent list it clos try s.expect(s.at("/pane/{d}/name", .{try s.focused()}), s.at("{s}\n", .{a})); } +test "other-files: two sessions on one state file share Recent: what one opened and closed is in the next one's, and each reads the other's on use" { + var tmp = std.testing.tmpDir(.{}); + defer tmp.cleanup(); + try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "a.txt", .data = "one\ntwo\nthree\n" }); + try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "b.txt", .data = "bee\nsea\n" }); + var dir_buf: [std.fs.max_path_bytes]u8 = undefined; + const dir = dir_buf[0..try tmp.dir.realPath(std.testing.io, &dir_buf)]; + var one = try Session.initShared(std.testing.allocator, dir); + defer one.deinit(); + const a = one.at("{s}/a.txt", .{dir}); + try one.write("/look", one.at("{s}:3\n", .{a})); + try one.write(one.at("/pane/{d}/ctl", .{try one.focused()}), "Del\n"); + // A session started after it lists the file closed, at its dot. + var two = try Session.initShared(std.testing.allocator, dir); + defer two.deinit(); + try std.testing.expect(has(try two.read("/recent"), two.at("closed {s}\n", .{a}))); + try std.testing.expect(has(try listing(&two, "Recent"), "a.txt:3:")); + // What it opens and closes is in the first one's, read there on use. + const b = two.at("{s}/b.txt", .{dir}); + try two.write("/look", two.at("{s}:2\n", .{b})); + try std.testing.expect(has(try two.read("/recent"), two.at("open {s}\n", .{b}))); + try two.write(two.at("/pane/{d}/ctl", .{try two.focused()}), "Del\n"); + try std.testing.expect(has(try one.read("/recent"), one.at("closed {s}\n", .{b}))); + try std.testing.expect(has(try one.read("/recent"), one.at("closed {s}\n", .{a}))); + try std.testing.expect(has(try listing(&one, "Recent"), "b.txt:2:")); +} + test "other-files: Back and Forward over a closed file's entries: one reopen is that file's pane in every entry, so the next step moves" { var tmp = std.testing.tmpDir(.{}); defer tmp.cleanup(); |
