diff --git a/helix-term/src/ui/picker.rs b/helix-term/src/ui/picker.rs index 821a282cf..35597843b 100644 --- a/helix-term/src/ui/picker.rs +++ b/helix-term/src/ui/picker.rs @@ -763,6 +763,7 @@ pub type DynQueryCallback = pub struct DynamicPicker { file_picker: FilePicker, query_callback: DynQueryCallback, + query: String, } impl DynamicPicker { @@ -772,6 +773,7 @@ impl DynamicPicker { Self { file_picker, query_callback, + query: String::new(), } } } @@ -782,14 +784,15 @@ impl Component for DynamicPicker { } fn handle_event(&mut self, event: &Event, cx: &mut Context) -> EventResult { - let prev_query = self.file_picker.picker.prompt.line().to_owned(); let event_result = self.file_picker.handle_event(event, cx); let current_query = self.file_picker.picker.prompt.line(); - if *current_query == prev_query || matches!(event_result, EventResult::Ignored(_)) { + if !matches!(event, Event::IdleTimeout) || self.query == *current_query { return event_result; } + self.query.clone_from(current_query); + let new_options = (self.query_callback)(current_query.to_owned(), cx.editor); cx.jobs.callback(async move {