diff options
| author | Gabriel Schneider <[email protected]> | 2026-10-01 07:56:48 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-10-01 08:53:11 -0300 |
| commit | 6c82d06cd2a15d724b8e82e1128fa15dc9e35d05 (patch) | |
| tree | 1c13f10465ce797333f8712d95d587af97ca2bc0 /src/file_watch.zig | |
| parent | 989f2bae90fde52b5dd36b57c31f535dd011461e (diff) | |
| download | pardes-6c82d06cd2a15d724b8e82e1128fa15dc9e35d05.tar.gz pardes-6c82d06cd2a15d724b8e82e1128fa15dc9e35d05.zip | |
Restore reads a clean file from disk, and an unsaved one whose file changed since the Dump is said changed, its first Save asking before overwriting it
A Restore put back the dump's copy of every file pane and armed the
watch with the disk as it now was, so a file changed on disk after the
Dump came back as its old text, marked clean, and the next Save wrote
the old text over the new without a word.
A clean file pane's text is now not in the dump: Restore reads its file
(an older dump's copy is read past too, and used only when the file is
gone). An unsaved pane keeps its text once, base64, the plain copy beside
it dropped, with the hash of the file it was read against
(`disk_hash`); a Restore that finds another there says the file changed
on disk, and Save asks once before overwriting it, as for a change seen
while it was open. file_watch.zig's own tests were never collected (no
test root imported it): main.zig's test block does now, and the restored
watch test says what a clean restore now reads.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/file_watch.zig')
| -rw-r--r-- | src/file_watch.zig | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/file_watch.zig b/src/file_watch.zig index 6c746e74..46764a73 100644 --- a/src/file_watch.zig +++ b/src/file_watch.zig @@ -687,11 +687,14 @@ test "restored file watches preserve snapshots and accept later disk changes" { else => {}, }; try std.testing.expect(armed and watches[id] != null); - try std.testing.expectEqualStrings("restored snapshot\n", pane.file.?.content); + // A clean pane's text is its file's, read at the Restore: a dump + // that kept other text (an older dump) is not what comes back. + const restored: []const u8 = if (case.dirty) "restored snapshot\n" else "disk baseline\n"; + try std.testing.expectEqualStrings(restored, pane.file.?.content); try std.testing.expectEqual(@as(usize, 0), pane.file.?.history.undo_len); try std.testing.expectEqual(case.dirty, pane.file.?.revision != pane.file.?.saved_revision); _ = reloadChanged(core, io, gpa, &watches); - try std.testing.expectEqualStrings("restored snapshot\n", pane.file.?.content); + try std.testing.expectEqualStrings(restored, pane.file.?.content); try tmp.dir.writeFile(io, .{ .sub_path = "watched", .data = "later disk save\n" }); _ = reloadChanged(core, io, gpa, &watches); @@ -704,9 +707,9 @@ test "restored file watches preserve snapshots and accept later disk changes" { } try std.testing.expectEqualStrings("later disk save\n", pane.file.?.content); pardes.panes.File.undo(core, pane); - try std.testing.expectEqualStrings("restored snapshot\n", pane.file.?.content); + try std.testing.expectEqualStrings(restored, pane.file.?.content); _ = reloadChanged(core, io, gpa, &watches); - try std.testing.expectEqualStrings("restored snapshot\n", pane.file.?.content); + try std.testing.expectEqualStrings(restored, pane.file.?.content); } } |
