Compare commits

...

1 Commits

Author SHA1 Message Date
Agus Zubiaga
f3ffbcc5ab commit view: Join file diff tasks
Co-authored-by: MrSubidubi <dev@bahn.sh>
2025-12-10 12:02:47 -03:00

View File

@@ -222,7 +222,12 @@ impl CommitView {
let repository_clone = repository.clone(); let repository_clone = repository.clone();
cx.spawn(async move |this, cx| { cx.spawn(async move |this, cx| {
for file in commit_diff.files { let diff_tasks = commit_diff.files.into_iter().map(|file| {
let this = this.clone();
let language_registry = language_registry.clone();
let commit_sha = commit_sha.clone();
let repository_clone = repository_clone.clone();
cx.spawn(async move |cx| {
let is_deleted = file.new_text.is_none(); let is_deleted = file.new_text.is_none();
let new_text = file.new_text.unwrap_or_default(); let new_text = file.new_text.unwrap_or_default();
let old_text = file.old_text; let old_text = file.old_text;
@@ -259,7 +264,8 @@ impl CommitView {
let snapshot = buffer.read(cx).snapshot(); let snapshot = buffer.read(cx).snapshot();
let path = snapshot.file().unwrap().path().clone(); let path = snapshot.file().unwrap().path().clone();
let excerpt_ranges = { let excerpt_ranges = {
let mut hunks = buffer_diff.read(cx).hunks(&snapshot, cx).peekable(); let mut hunks =
buffer_diff.read(cx).hunks(&snapshot, cx).peekable();
if hunks.peek().is_none() { if hunks.peek().is_none() {
vec![language::Point::zero()..snapshot.max_point()] vec![language::Point::zero()..snapshot.max_point()]
} else { } else {
@@ -279,10 +285,13 @@ impl CommitView {
multibuffer.add_diff(buffer_diff, cx); multibuffer.add_diff(buffer_diff, cx);
}); });
})?; })?;
}
anyhow::Ok(()) anyhow::Ok(())
}) })
});
futures::future::try_join_all(diff_tasks).await
})
.detach(); .detach();
let snapshot = repository.read(cx).snapshot(); let snapshot = repository.read(cx).snapshot();