Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions helix-term/src/ui/picker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,7 @@ pub type DynQueryCallback<T> =
pub struct DynamicPicker<T: ui::menu::Item + Send> {
file_picker: FilePicker<T>,
query_callback: DynQueryCallback<T>,
query: String,
}

impl<T: ui::menu::Item + Send> DynamicPicker<T> {
Expand All @@ -705,6 +706,7 @@ impl<T: ui::menu::Item + Send> DynamicPicker<T> {
Self {
file_picker,
query_callback,
query: String::new(),
}
}
}
Expand All @@ -715,14 +717,15 @@ impl<T: Item + Send + 'static> Component for DynamicPicker<T> {
}

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 {
Expand Down