From 5b23998376ef254effe61c7423df601c533e1037 Mon Sep 17 00:00:00 2001 From: CJ van den Berg Date: Thu, 23 Oct 2025 19:02:29 +0200 Subject: [PATCH] fix: don't restore files from project that no longer exist --- src/Project.zig | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/Project.zig b/src/Project.zig index 7c26ad7..67231c1 100644 --- a/src/Project.zig +++ b/src/Project.zig @@ -197,9 +197,12 @@ pub fn restore_state_v1(self: *Self, data: []const u8) !void { } tp.trace(tp.channel.debug, .{ "restore_state_v1", "file", path, mtime, row, col }); self.longest_file_path = @max(self.longest_file_path, path.len); - const stat = std.fs.cwd().statFile(path) catch { - try self.update_mru_internal(path, mtime, row, col); - continue; + const stat = std.fs.cwd().statFile(path) catch |e| switch (e) { + error.FileNotFound => continue, + else => { + try self.update_mru_internal(path, mtime, row, col); + continue; + }, }; switch (stat.kind) { .sym_link, .file => try self.update_mru_internal(path, mtime, row, col), @@ -264,9 +267,12 @@ pub fn restore_state_v0(self: *Self, data: []const u8) error{ }) { tp.trace(tp.channel.debug, .{ "restore_state_v0", "file", path, mtime, row, col }); self.longest_file_path = @max(self.longest_file_path, path.len); - const stat = std.fs.cwd().statFile(path) catch { - try self.update_mru_internal(path, mtime, row, col); - continue; + const stat = std.fs.cwd().statFile(path) catch |e| switch (e) { + error.FileNotFound => continue, + else => { + try self.update_mru_internal(path, mtime, row, col); + continue; + }, }; switch (stat.kind) { .sym_link, .file => try self.update_mru_internal(path, mtime, row, col),