From 320088f1fa1cc09117a6d7622b781d0a4aa31659 Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Wed, 24 Jan 2024 20:56:39 -0700 Subject: [PATCH] Fix panic from unwrapping a relativize() --- crates/project/src/worktree.rs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/crates/project/src/worktree.rs b/crates/project/src/worktree.rs index 4bd5e62994..c94385f14f 100644 --- a/crates/project/src/worktree.rs +++ b/crates/project/src/worktree.rs @@ -970,13 +970,14 @@ impl LocalWorktree { let mut index_task = None; let snapshot = this.update(&mut cx, |this, _| this.as_local().unwrap().snapshot())?; if let Some(repo) = snapshot.repository_for_path(&path) { - let repo_path = repo.work_directory.relativize(&snapshot, &path).unwrap(); - if let Some(repo) = snapshot.git_repositories.get(&*repo.work_directory) { - let repo = repo.repo_ptr.clone(); - index_task = Some( - cx.background_executor() - .spawn(async move { repo.lock().load_index_text(&repo_path) }), - ); + if let Some(repo_path) = repo.work_directory.relativize(&snapshot, &path) { + if let Some(repo) = snapshot.git_repositories.get(&*repo.work_directory) { + let repo = repo.repo_ptr.clone(); + index_task = Some( + cx.background_executor() + .spawn(async move { repo.lock().load_index_text(&repo_path) }), + ); + } } }