diff --git a/crates/file_finder/src/file_finder.rs b/crates/file_finder/src/file_finder.rs index 9877cef3d8..b433193456 100644 --- a/crates/file_finder/src/file_finder.rs +++ b/crates/file_finder/src/file_finder.rs @@ -129,7 +129,7 @@ impl FileFinder { } fn project_updated(&mut self, _: ModelHandle, cx: &mut ViewContext) { - self.spawn_search(self.latest_search_query.clone(), cx) + self.spawn_search(self.picker.read(cx).query(cx), cx) .detach(); } @@ -379,7 +379,7 @@ mod tests { // Simulate a search being cancelled after the time limit, // returning only a subset of the matches that would have been found. - finder.spawn_search(query.clone(), cx).detach(); + drop(finder.spawn_search(query.clone(), cx)); finder.set_matches( finder.latest_search_id, true, // did-cancel @@ -389,7 +389,7 @@ mod tests { ); // Simulate another cancellation. - finder.spawn_search(query.clone(), cx).detach(); + drop(finder.spawn_search(query.clone(), cx)); finder.set_matches( finder.latest_search_id, true, // did-cancel diff --git a/crates/picker/src/picker.rs b/crates/picker/src/picker.rs index f234672478..199429b07e 100644 --- a/crates/picker/src/picker.rs +++ b/crates/picker/src/picker.rs @@ -150,6 +150,10 @@ impl Picker { self } + pub fn query(&self, cx: &AppContext) -> String { + self.query_editor.read(cx).text(cx) + } + fn on_query_editor_event( &mut self, _: ViewHandle, @@ -171,7 +175,7 @@ impl Picker { fn update_matches(&mut self, cx: &mut ViewContext) { if let Some(delegate) = self.delegate.upgrade(cx) { - let query = self.query_editor.read(cx).text(cx); + let query = self.query(cx); let update = delegate.update(cx, |d, cx| d.update_matches(query, cx)); cx.notify(); self.update_task = Some(cx.spawn(|this, mut cx| async move {