Load diff base from correct relative path

This commit is contained in:
Julia 2022-10-04 20:42:01 -04:00
parent 836b536a90
commit 3f4be5521c
2 changed files with 15 additions and 8 deletions

View File

@ -4673,13 +4673,18 @@ impl Project {
None => return,
};
let relative_repo = match path.strip_prefix(repo.content_path) {
Ok(relative_repo) => relative_repo.to_owned(),
Err(_) => return,
};
let shared_remote_id = self.shared_remote_id();
let client = self.client.clone();
cx.spawn(|_, mut cx| async move {
let diff_base = cx
.background()
.spawn(async move { repo.repo.lock().load_index(&path) })
.spawn(async move { repo.repo.lock().load_index(&relative_repo) })
.await;
let buffer_id = buffer.update(&mut cx, |buffer, cx| {

View File

@ -667,13 +667,15 @@ impl LocalWorktree {
cx.spawn(|this, mut cx| async move {
let text = fs.load(&abs_path).await?;
let diff_base = if let Some(repo) = snapshot.repo_for(&abs_path) {
cx.background()
.spawn({
let path = path.clone();
async move { repo.repo.lock().load_index(&path) }
})
.await
let diff_base = if let Some(repo) = snapshot.repo_for(&path) {
if let Ok(repo_relative) = path.strip_prefix(repo.content_path) {
let repo_relative = repo_relative.to_owned();
cx.background()
.spawn(async move { repo.repo.lock().load_index(&repo_relative) })
.await
} else {
None
}
} else {
None
};