summaryrefslogtreecommitdiff
path: root/src/ninep/ctl.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-10-01 10:02:59 -0300
committerGabriel Schneider <[email protected]>2026-10-01 10:36:27 -0300
commit9b641cbe3dc6c226be158e5051afafb9eb86c122 (patch)
treebca8b426eeea3b7a2587164c4cacab8b6278f6bb /src/ninep/ctl.zig
parent70881bb4edd15fe918ee5fed4ed3e8922bc7fc6a (diff)
downloadpardes-9b641cbe3dc6c226be158e5051afafb9eb86c122.tar.gz
pardes-9b641cbe3dc6c226be158e5051afafb9eb86c122.zip
An unsaved pane restored from a dump that says nothing of its disk (no disk_hash, an older dump) asks at its first Save, as for a file changed on disk
What its text was read against is unknown, so a Save could write over a newer file without a word; it now asks once first. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/ninep/ctl.zig')
-rw-r--r--src/ninep/ctl.zig19
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)"));
+}