Do not panic on non-worktree file indexing

This commit is contained in:
Kirill Bulatov 2023-12-18 13:05:25 +02:00
parent 4e544545d1
commit 7e21e0f0eb

View File

@ -963,7 +963,7 @@ impl LocalWorktree {
let mut index_task = None; let mut index_task = None;
let snapshot = this.read_with(&cx, |this, _| this.as_local().unwrap().snapshot()); let snapshot = this.read_with(&cx, |this, _| this.as_local().unwrap().snapshot());
if let Some(repo) = snapshot.repository_for_path(&path) { if let Some(repo) = snapshot.repository_for_path(&path) {
let repo_path = repo.work_directory.relativize(&snapshot, &path).unwrap(); if let Some(repo_path) = repo.work_directory.relativize(&snapshot, &path) {
if let Some(repo) = snapshot.git_repositories.get(&*repo.work_directory) { if let Some(repo) = snapshot.git_repositories.get(&*repo.work_directory) {
let repo = repo.repo_ptr.clone(); let repo = repo.repo_ptr.clone();
index_task = Some( index_task = Some(
@ -971,6 +971,13 @@ impl LocalWorktree {
.spawn(async move { repo.lock().load_index_text(&repo_path) }), .spawn(async move { repo.lock().load_index_text(&repo_path) }),
); );
} }
} else {
log::warn!(
"Skipping loading index text from path {:?} is not in repository {:?}",
path,
repo.work_directory,
);
}
} }
let diff_base = if let Some(index_task) = index_task { let diff_base = if let Some(index_task) = index_task {