From 35e72930c11af5563da9d62df2b74a7439f36653 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 29 Sep 2026 04:18:04 -0300 Subject: A file changed on disk never reloads over unsaved edits A watched file rewritten on disk was loaded over a buffer's unsaved edits and its dirty flag cleared, so Exit and Del no longer asked about them. A clean buffer still reloads; one with edits keeps its text and stays dirty, says changed on disk (get reloads it, Save overwrites it), logs changed , and its Save warns once before overwriting the newer file, as acme's Put refuses a file modified since read (exec.c:577); get asks as ever (winclean, exec.c:513). The restored-watch test's dirty case now keeps the snapshot, and the filewatch snapshot script (re-recorded by name) checks both halves: the edited pane keeps its edit and says so, the clean one reloads. Co-Authored-By: Claude Opus 5.5 --- src/exec.zig | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/exec.zig') diff --git a/src/exec.zig b/src/exec.zig index b8312a21..953ae0f3 100644 --- a/src/exec.zig +++ b/src/exec.zig @@ -249,6 +249,16 @@ pub fn saveFile(p: *Pardes, id: usize) void { const pane = p.panes[id] orelse return; const f = if (pane.file) |*file| file else return; if (f.output != null) return; // nothing behind it yet: saveTo, with a path + // Its file changed on disk under these edits: once, as acme's Put says + // "modified since last read" (exec.c:577), and the next Save writes. + if (f.disk_newer != null) { + if (!f.disk_newer_warned) { + f.disk_newer_warned = true; + var said: [Pardes.SavePath.cap + 64]u8 = undefined; + return p.reportFailure(id, std.fmt.bufPrint(&said, "{s} modified on disk since read (Save again to overwrite)", .{f.path}) catch "modified on disk since read (Save again to overwrite)"); + } + f.disk_newer = null; + } p.emit(.{ .save_file = .{ .pane = @intCast(id) } }); } -- cgit v1.3