mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-30 22:34:13 +00:00
Don't cancel match updates when picker query changes
The file finder often cancels an in-progress match task when the project updates. But it still needs to take the matches that it did find and add them to its results. So we should not cancel the entire task, as this will cause the partial results to be discarded.
This commit is contained in:
parent
47379677f2
commit
717ebe6a4c
1 changed files with 3 additions and 5 deletions
|
@ -18,7 +18,6 @@ pub struct Picker<D: PickerDelegate> {
|
||||||
delegate: WeakViewHandle<D>,
|
delegate: WeakViewHandle<D>,
|
||||||
query_editor: ViewHandle<Editor>,
|
query_editor: ViewHandle<Editor>,
|
||||||
list_state: UniformListState,
|
list_state: UniformListState,
|
||||||
update_task: Option<Task<()>>,
|
|
||||||
max_size: Vector2F,
|
max_size: Vector2F,
|
||||||
confirmed: bool,
|
confirmed: bool,
|
||||||
}
|
}
|
||||||
|
@ -136,7 +135,6 @@ impl<D: PickerDelegate> Picker<D> {
|
||||||
let this = Self {
|
let this = Self {
|
||||||
query_editor,
|
query_editor,
|
||||||
list_state: Default::default(),
|
list_state: Default::default(),
|
||||||
update_task: None,
|
|
||||||
delegate,
|
delegate,
|
||||||
max_size: vec2f(500., 420.),
|
max_size: vec2f(500., 420.),
|
||||||
confirmed: false,
|
confirmed: false,
|
||||||
|
@ -178,7 +176,7 @@ impl<D: PickerDelegate> Picker<D> {
|
||||||
let query = self.query(cx);
|
let query = self.query(cx);
|
||||||
let update = delegate.update(cx, |d, cx| d.update_matches(query, cx));
|
let update = delegate.update(cx, |d, cx| d.update_matches(query, cx));
|
||||||
cx.notify();
|
cx.notify();
|
||||||
self.update_task = Some(cx.spawn(|this, mut cx| async move {
|
cx.spawn(|this, mut cx| async move {
|
||||||
update.await;
|
update.await;
|
||||||
this.update(&mut cx, |this, cx| {
|
this.update(&mut cx, |this, cx| {
|
||||||
if let Some(delegate) = this.delegate.upgrade(cx) {
|
if let Some(delegate) = this.delegate.upgrade(cx) {
|
||||||
|
@ -191,10 +189,10 @@ impl<D: PickerDelegate> Picker<D> {
|
||||||
};
|
};
|
||||||
this.list_state.scroll_to(target);
|
this.list_state.scroll_to(target);
|
||||||
cx.notify();
|
cx.notify();
|
||||||
this.update_task.take();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}));
|
})
|
||||||
|
.detach()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue