diff --git a/crates/language/src/buffer.rs b/crates/language/src/buffer.rs index d1dfb9ec22..9d386c14ad 100644 --- a/crates/language/src/buffer.rs +++ b/crates/language/src/buffer.rs @@ -662,10 +662,9 @@ impl Buffer { self.file = Some(new_file); task } - + pub fn update_git(&mut self, cx: &mut ModelContext) { //Grab head text - self.git_diff_recalc(cx); } diff --git a/crates/project/src/git_repository.rs b/crates/project/src/git_repository.rs index c27b1ba385..4b46b18391 100644 --- a/crates/project/src/git_repository.rs +++ b/crates/project/src/git_repository.rs @@ -1,7 +1,7 @@ use anyhow::Result; use git2::{Repository as LibGitRepository, RepositoryOpenFlags as LibGitRepositoryOpenFlags}; use parking_lot::Mutex; -use std::{path::Path, sync::Arc, ffi::OsStr}; +use std::{ffi::OsStr, path::Path, sync::Arc}; use util::ResultExt; #[derive(Clone)] diff --git a/crates/project/src/worktree.rs b/crates/project/src/worktree.rs index beef854470..4885ce104a 100644 --- a/crates/project/src/worktree.rs +++ b/crates/project/src/worktree.rs @@ -636,6 +636,7 @@ impl LocalWorktree { let path = Arc::from(path); let abs_path = self.absolutize(&path); let fs = self.fs.clone(); + let snapshot = self.snapshot(); let files_included = cx .global::() @@ -651,12 +652,11 @@ impl LocalWorktree { files_included, settings::GitFilesIncluded::All | settings::GitFilesIncluded::OnlyTracked ) { - - - let fs = fs.clone(); - let abs_path = abs_path.clone(); - let opt_future = async move { fs.load_head_text(&abs_path).await }; - let results = cx.background().spawn(task).await; + let results = if let Some(repo) = snapshot.repo_for(&abs_path) { + repo.load_head_text(&abs_path).await + } else { + None + }; if files_included == settings::GitFilesIncluded::All { results.or_else(|| Some(text.clone()))