diff --git a/crates/project/src/project_search.rs b/crates/project/src/project_search.rs index 520c2006ae0cbc331250a1b094160a51d2a9ea9c..d518af378a2738652e52bae2f46ab768d4cc3a51 100644 --- a/crates/project/src/project_search.rs +++ b/crates/project/src/project_search.rs @@ -251,17 +251,22 @@ impl Search { find_all_matches_tx: Sender>, mut cx: AsyncApp, ) { + let mut rx = pin!(rx.ready_chunks(64)); _ = maybe!(async move { - while let Ok(requested_path) = rx.recv().await { - let Some(buffer) = self - .buffer_store - .update(&mut cx, |this, cx| this.open_buffer(requested_path, cx))? - .await - .log_err() - else { - continue; - }; - find_all_matches_tx.send(buffer).await?; + while let Some(requested_paths) = rx.next().await { + let buffers = self.buffer_store.update(&mut cx, |this, cx| { + requested_paths + .into_iter() + .map(|path| this.open_buffer(path, cx)) + .collect::>() + })?; + let buffers = futures::future::join_all(buffers).await; + + for b in buffers { + if let Some(buffer) = b.log_err() { + find_all_matches_tx.send(buffer).await?; + } + } } Result::<_, anyhow::Error>::Ok(()) })