mirror of
https://github.com/zed-industries/zed.git
synced 2025-02-06 18:46:49 +00:00
Open searched buffers in parallel
This commit is contained in:
parent
5be93044f6
commit
2147db9b41
1 changed files with 23 additions and 10 deletions
|
@ -2148,23 +2148,36 @@ impl Project {
|
||||||
.values()
|
.values()
|
||||||
.filter_map(|b| b.upgrade(cx))
|
.filter_map(|b| b.upgrade(cx))
|
||||||
.collect::<HashSet<_>>();
|
.collect::<HashSet<_>>();
|
||||||
cx.spawn(|this, mut cx| async move {
|
cx.spawn(|this, cx| async move {
|
||||||
for buffer in &open_buffers {
|
for buffer in &open_buffers {
|
||||||
let snapshot = buffer.read_with(&cx, |buffer, _| buffer.snapshot());
|
let snapshot = buffer.read_with(&cx, |buffer, _| buffer.snapshot());
|
||||||
buffers_tx.send((buffer.clone(), snapshot)).await?;
|
buffers_tx.send((buffer.clone(), snapshot)).await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let open_buffers = Rc::new(RefCell::new(open_buffers));
|
||||||
while let Some(project_path) = matching_paths_rx.next().await {
|
while let Some(project_path) = matching_paths_rx.next().await {
|
||||||
if let Some(buffer) = this
|
if buffers_tx.is_closed() {
|
||||||
.update(&mut cx, |this, cx| this.open_buffer(project_path, cx))
|
break;
|
||||||
.await
|
|
||||||
.log_err()
|
|
||||||
{
|
|
||||||
if !open_buffers.contains(&buffer) {
|
|
||||||
let snapshot = buffer.read_with(&cx, |buffer, _| buffer.snapshot());
|
|
||||||
buffers_tx.send((buffer, snapshot)).await?;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let this = this.clone();
|
||||||
|
let open_buffers = open_buffers.clone();
|
||||||
|
let buffers_tx = buffers_tx.clone();
|
||||||
|
cx.spawn(|mut cx| async move {
|
||||||
|
if let Some(buffer) = this
|
||||||
|
.update(&mut cx, |this, cx| this.open_buffer(project_path, cx))
|
||||||
|
.await
|
||||||
|
.log_err()
|
||||||
|
{
|
||||||
|
if open_buffers.borrow_mut().insert(buffer.clone()) {
|
||||||
|
let snapshot = buffer.read_with(&cx, |buffer, _| buffer.snapshot());
|
||||||
|
buffers_tx.send((buffer, snapshot)).await?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok::<_, anyhow::Error>(())
|
||||||
|
})
|
||||||
|
.detach();
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok::<_, anyhow::Error>(())
|
Ok::<_, anyhow::Error>(())
|
||||||
|
|
Loading…
Reference in a new issue