Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
editor: Limit the amount of git processes spawned per multibuffer (#41472)
Lukas Wirth3583e129d197
diff --git a/crates/editor/src/git/blame.rs b/crates/editor/src/git/blame.rsindex 3d83e3a5cce..4f210cc9db8 100644--- a/crates/editor/src/git/blame.rs+++ b/crates/editor/src/git/blame.rs@@ -1,6 +1,7 @@use crate::Editor;use anyhow::Result;use collections::HashMap;+use futures::StreamExt;use git::{GitHostingProviderRegistry, GitRemote, Oid,blame::{Blame, BlameEntry, ParsedCommitMessage},@@ -507,7 +508,7 @@ impl GitBlame {let buffer_edits = buffer.update(cx, |buffer, _| buffer.subscribe());let blame_buffer = project.blame_buffer(&buffer, None, cx);- Some((id, snapshot, buffer_edits, blame_buffer))+ Some(async move { (id, snapshot, buffer_edits, blame_buffer.await) })}).collect::<Vec<_>>()});@@ -517,10 +518,14 @@ impl GitBlame {let (result, errors) = cx.background_spawn({async move {+ let blame = futures::stream::iter(blame)+ .buffered(4)+ .collect::<Vec<_>>()+ .await;let mut res = vec![];let mut errors = vec![];for (id, snapshot, buffer_edits, blame) in blame {- match blame.await {+ match blame {Ok(Some(Blame {entries,messages,diff --git a/crates/git/src/repository.rs b/crates/git/src/repository.rsindex 06bc5ec4114..eaefd4ba22c 100644--- a/crates/git/src/repository.rs+++ b/crates/git/src/repository.rs@@ -1279,18 +1279,17 @@ impl GitRepository for RealGitRepository {.remote_url("upstream").or_else(|| self.remote_url("origin"));- self.executor- .spawn(async move {- crate::blame::Blame::for_path(- &git_binary_path,- &working_directory?,- &path,- &content,- remote_url,- )- .await- })- .boxed()+ async move {+ crate::blame::Blame::for_path(+ &git_binary_path,+ &working_directory?,+ &path,+ &content,+ remote_url,+ )+ .await+ }+ .boxed()}fn diff(&self, diff: DiffType) -> BoxFuture<'_, Result<String>> {