summaryrefslogtreecommitdiff
path: root/src/File.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-09-29 03:31:23 -0300
committerGabriel Schneider <[email protected]>2026-10-01 00:12:15 -0300
commit3e941015ebd2da88a296479f407e9bbf06287234 (patch)
tree91178a9c4d3a05994cc2390cd7906b3b63e5be32 /src/File.zig
parent52d822eee271c53f072c94d3fc7f262e1659eff1 (diff)
downloadpardes-3e941015ebd2da88a296479f407e9bbf06287234.tar.gz
pardes-3e941015ebd2da88a296479f407e9bbf06287234.zip
A pane restored with unsaved text is asked about before it is thrown away
Exit, Restore, Del and get warn only about a pane edited since it was opened, which its saved hash says (set at its first edit). A pane a Dump kept dirty came back with no hash, so a restored session quit at once over it. Restoring one dirty now gives it a hash its text does not match. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/File.zig')
-rw-r--r--src/File.zig4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/File.zig b/src/File.zig
index 6a1ac319..810bc766 100644
--- a/src/File.zig
+++ b/src/File.zig
@@ -809,6 +809,10 @@ pub fn restore(p: *Pardes, id: usize, src: dump.Pane) !*Pane {
.location_rows = location_rows,
.scroll = src.scroll,
.revision = @intFromBool(saved.dirty),
+ // Restored with unsaved text, it has text to lose as an edited pane
+ // has: a hash its text does not match, so Exit, Restore, Del and
+ // get ask first (builtins.warnModifiedIn reads only edited panes).
+ .saved_hash = if (saved.dirty) std.hash.Wyhash.hash(0, content) +% 1 else null,
.history = history,
};
pane.file.?.tree_context = saved.tree_context and supportsContext(pane);