From 880d33045970e72537295946a69bab7b4ec50470 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Tue, 23 Jan 2024 15:36:21 -0800 Subject: [PATCH] Clear selected index when updating file finder's matches --- crates/file_finder/src/file_finder.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/crates/file_finder/src/file_finder.rs b/crates/file_finder/src/file_finder.rs index 042cfccf0d..672ed6272e 100644 --- a/crates/file_finder/src/file_finder.rs +++ b/crates/file_finder/src/file_finder.rs @@ -115,11 +115,13 @@ impl FileFinder { } impl EventEmitter for FileFinder {} + impl FocusableView for FileFinder { fn focus_handle(&self, cx: &AppContext) -> FocusHandle { self.picker.focus_handle(cx) } } + impl Render for FileFinder { fn render(&mut self, _cx: &mut ViewContext) -> impl IntoElement { v_flex().w(rems(34.)).child(self.picker.clone()) @@ -385,6 +387,7 @@ impl FileFinderDelegate { let did_cancel = cancel_flag.load(atomic::Ordering::Relaxed); picker .update(&mut cx, |picker, cx| { + picker.delegate.selected_index.take(); picker .delegate .set_search_matches(search_id, did_cancel, query, matches, cx) @@ -623,6 +626,7 @@ impl PickerDelegate for FileFinderDelegate { if raw_query.is_empty() { let project = self.project.read(cx); self.latest_search_id = post_inc(&mut self.search_count); + self.selected_index.take(); self.matches = Matches { history: self .history_items