diff options
Diffstat (limited to 'src/file_watch.zig')
| -rw-r--r-- | src/file_watch.zig | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/file_watch.zig b/src/file_watch.zig index b262e8ce..71a4680d 100644 --- a/src/file_watch.zig +++ b/src/file_watch.zig @@ -60,6 +60,10 @@ pub const Watch = struct { kq: c_int = -1, serial: u32, generation: Generation, + /// The path last read while watched (its hash): its going away later is + /// a deletion to say, where a path never there (a pane renamed to a new + /// name) is not. + existed: ?u64 = null, }; /// The final slot is the one non-pane watched payload: the active ThemeFile. @@ -440,7 +444,12 @@ pub fn reloadPane( } if (pane.file) |file| { - const bytes = filesystem.read(core, file.path) catch return false; + const bytes = filesystem.read(core, file.path) catch |err| { + // Gone from under the pane: said once, the text kept. + if (err == error.FileNotFound and watched.existed == std.hash.Wyhash.hash(0, file.path)) pardes.panes.File.deleted(core, @intCast(id)); + return false; + }; + if (watches[id]) |*live| live.existed = std.hash.Wyhash.hash(0, file.path); defer core.gpa.free(bytes); const hash = std.hash.Wyhash.hash(0, bytes); switch (watched.generation) { @@ -517,6 +526,7 @@ pub fn applyEffect( const bytes = filesystem.read(core, file.path) catch return false; defer core.gpa.free(bytes); watched.generation = .{ .text = std.hash.Wyhash.hash(0, bytes) }; + watched.existed = std.hash.Wyhash.hash(0, file.path); return false; }; return on and watches[id] != null and reloadPane(core, io, watches, id, false); |
