From 7eacefd8ace0aad93f8d2a71ad7a09442f349f57 Mon Sep 17 00:00:00 2001 From: Bennet Bo Fenner Date: Tue, 30 Sep 2025 22:01:45 +0200 Subject: [PATCH] worktree: Remove unwrap in BackgroundScanner::update_ignore_status (#39191) We've seen this panic come up in the last two weeks, which might be caused by #33592. However, we are not sure what paths can cause this `unwrap()` to fail. Therefore adding some logging around this, so that the next time someone opens a bug report we can further diagnose the issue. Fixes ZED-1F6 Release Notes: - Fixed an issue where Zed could crash when including specific paths in a global `.gitignore` files --- crates/worktree/src/worktree.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/crates/worktree/src/worktree.rs b/crates/worktree/src/worktree.rs index d3f1976500fb19d31a2d2f44c7d63933552eec15..813a1a1040257d6dd92485f693763938abc823be 100644 --- a/crates/worktree/src/worktree.rs +++ b/crates/worktree/src/worktree.rs @@ -4841,10 +4841,20 @@ impl BackgroundScanner { let mut entries_by_id_edits = Vec::new(); let mut entries_by_path_edits = Vec::new(); - let path = job + let Some(path) = job .abs_path .strip_prefix(snapshot.abs_path.as_path()) - .unwrap(); + .map_err(|_| { + anyhow::anyhow!( + "Failed to strip prefix '{}' from path '{}'", + snapshot.abs_path.as_path().display(), + job.abs_path.display() + ) + }) + .log_err() + else { + return; + }; if let Ok(Some(metadata)) = smol::block_on(self.fs.metadata(&job.abs_path.join(*DOT_GIT))) && metadata.is_dir