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/dump.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/dump.zig')
| -rw-r--r-- | src/dump.zig | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/dump.zig b/src/dump.zig index ca3751f2..1420ea8f 100644 --- a/src/dump.zig +++ b/src/dump.zig @@ -208,9 +208,16 @@ pub const LocationRow = struct { pub const File = struct { path: []const u8 = "", + /// The text, in older dumps plain and base64 both; now base64 alone, + /// and only for a pane whose text is not its file's on disk (unsaved, + /// an output, a file never written): a clean file's is read from disk. content: []const u8 = "", content_b64: []const u8 = "", dirty: bool = false, + /// An unsaved pane's: the hash of the file on disk its text was read + /// against. A Restore that finds another there says it changed, and + /// Save asks before overwriting it. + disk_hash: ?u64 = null, /// Its file was on disk when dumped: one gone by the Restore is said /// deleted, one never written (Config's new file) is not. True in /// older dumps. @@ -728,6 +735,7 @@ pub fn dumpState(p: *Pardes) !void { const body = try body_layer.bodyText(p, arena, pane); const scroll: usize = @intCast(@max(0, pane.scroll())); var dp: Pane = if (pane.file) |*f| try pardes.panes.File.dumpPane( + p, arena, pane, f, |
