diff options
Diffstat (limited to 'src/ninep/ctl.zig')
| -rw-r--r-- | src/ninep/ctl.zig | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig index 16fbabb4..554333bb 100644 --- a/src/ninep/ctl.zig +++ b/src/ninep/ctl.zig @@ -4409,3 +4409,22 @@ test "a command or a terminal refused for room is refused before anything is log p.update(.{ .resize = .{ .cols = 80, .rows = 24 } }); } } + +test "an unsaved pane from a dump that says nothing of its disk asks at its first Save" { + if (comptime !pardes.hosted) return; + const gpa = testing.allocator; + var tmp = testing.tmpDir(.{}); + defer tmp.cleanup(); + try tmp.dir.writeFile(testing.io, .{ .sub_path = "old.txt", .data = "disk\n" }); + var dir_buf: [4096]u8 = undefined; + const dir = dir_buf[0..try tmp.dir.realPath(testing.io, &dir_buf)]; + var path_buf: [4200]u8 = undefined; + const path = try std.fmt.bufPrint(&path_buf, "{s}/old.txt", .{dir}); + const p = try withFile(gpa, "x\n"); + defer p.deinit(); + const id = p.freeSlot().?; + const pane = try pardes.panes.File.restore(p, id, .{ .kind = .file, .tag = "", .body = "", .file = .{ .path = path, .content = "unsaved\n", .dirty = true } }); + try testing.expect(pane.file.?.disk_newer != null); + pardes.exec.saveFile(p, id); + try testing.expect(th.logHas(p, "modified on disk since read (Save again to overwrite)")); +} |
