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/file_watch.zig | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/file_watch.zig') diff --git a/src/file_watch.zig b/src/file_watch.zig index 5d998470..b262e8ce 100644 --- a/src/file_watch.zig +++ b/src/file_watch.zig @@ -665,6 +665,13 @@ test "restored file watches preserve snapshots and accept later disk changes" { try tmp.dir.writeFile(io, .{ .sub_path = "watched", .data = "later disk save\n" }); _ = reloadChanged(core, io, gpa, &watches); + // A snapshot restored with unsaved text keeps it: a later disk + // change is said, never loaded over it (File.changed). + if (case.dirty) { + try std.testing.expectEqualStrings("restored snapshot\n", pane.file.?.content); + try std.testing.expect(pane.file.?.disk_newer != null); + continue; + } 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); -- cgit v1.3