diff options
| author | Gabriel Schneider <[email protected]> | 2026-09-30 16:47:19 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-10-01 00:12:17 -0300 |
| commit | a15eabc3b9d98ef5f659ca82a2b0f2afb7451a39 (patch) | |
| tree | 1dd39a36cce0bf462a63c7adda037711be191f48 | |
| parent | 319325b74f3c97cad9988faebc7c6afda26cad08 (diff) | |
| download | pardes-a15eabc3b9d98ef5f659ca82a2b0f2afb7451a39.tar.gz pardes-a15eabc3b9d98ef5f659ca82a2b0f2afb7451a39.zip | |
A restored pane whose file is gone from disk comes back dirty, and Del asks before throwing its text away
A dump keeps a pane's text. Restored after its file was deleted, the pane
came back clean: the watch's baseline read of the missing file failed
quietly, and Del closed it without a word. Its text was then nowhere at
all. Restore now checks the file: a local path with nothing on disk comes
back as one deleted on disk, as the watch would have said. It says so
once, logs `changed N deleted`, and is dirty, so Del, Exit and Restore
ask first.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
| -rw-r--r-- | src/File.zig | 5 | ||||
| -rw-r--r-- | src/ninep/ctl.zig | 15 |
2 files changed, 20 insertions, 0 deletions
diff --git a/src/File.zig b/src/File.zig index 2046a7cd..78c84287 100644 --- a/src/File.zig +++ b/src/File.zig @@ -888,6 +888,11 @@ pub fn restore(p: *Pardes, id: usize, src: dump.Pane) !*Pane { pane.cols = @max(1, src.cols); pane.rows = @max(1, src.rows); if (output == null and filesystem.localPath(path) != null) p.emit(.{ .watch = .{ .pane = @intCast(id), .on = true, .mode = .baseline_disk } }); + // Its file gone from disk since the dump: its text is nowhere else now, + // so it comes back as one deleted on disk, dirty, and Del, Exit and + // Restore ask before throwing it away. + if (comptime pardes.hosted) if (output == null) if (filesystem.localPath(path)) |local| + if (@import("exec.zig").kindOf(local) == null) deleted(p, @intCast(id)); return pane; } diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig index 9a95a10f..549aa265 100644 --- a/src/ninep/ctl.zig +++ b/src/ninep/ctl.zig @@ -2525,6 +2525,21 @@ test "Kill with a name and nothing running says so and does not fail, as bare Ki try testing.expect(th.logHas(p, "Kill: nothing running")); } +test "a restored pane whose file is gone from disk comes back dirty, and Del asks first" { + if (comptime !pardes.hosted) return error.SkipZigTest; + const p = try withFile(testing.allocator, "kept text\n"); + defer p.deinit(); + try pane_files.nameBuffer(p, 0, "/tmp/pardes-restore-gone-xyz/f.txt", false); + try pardes.dump.dumpState(p); + const restored = try pardes.dump.restore(p, p.dump_out.?, "/tmp/pardes.dump.zon"); + defer restored.deinit(); + const again = restored.panes[restored.paneBySerial(restored.panes[0].?.serial).?].?; + try testing.expect(again.file.?.disk_gone); + const r = wr(restored, Node.of(again.serial, .ctl), "Del\n"); + try testing.expectEqual(Status.err, r.reply.status); + try testing.expect(std.mem.indexOf(u8, r.reply.ename, "Modified") != null); +} + test "a line starting with # runs as nothing at an exec or a ctl, silently" { const p = try withFile(testing.allocator, "x\n"); defer p.deinit(); |
