DynamicPicker: Reset idle timeout on refresh

If the new results shown by the picker select a file that hasn't been
previewed before, the idle timeout would not trigger highlighting on
that file. With this change, we reset the idle timeout and allow that
file to be highlighted on the next idle timeout event.
This commit is contained in:
Michael Davis 2022-12-07 16:24:32 -06:00 committed by Blaž Hrastnik
parent a7daa02346
commit 35cf972ce4

View File

@ -798,7 +798,7 @@ fn handle_event(&mut self, event: &Event, cx: &mut Context) -> EventResult {
cx.jobs.callback(async move { cx.jobs.callback(async move {
let new_options = new_options.await?; let new_options = new_options.await?;
let callback = let callback =
crate::job::Callback::EditorCompositor(Box::new(move |_editor, compositor| { crate::job::Callback::EditorCompositor(Box::new(move |editor, compositor| {
// Wrapping of pickers in overlay is done outside the picker code, // Wrapping of pickers in overlay is done outside the picker code,
// so this is fragile and will break if wrapped in some other widget. // so this is fragile and will break if wrapped in some other widget.
let picker = match compositor.find_id::<Overlay<DynamicPicker<T>>>(Self::ID) { let picker = match compositor.find_id::<Overlay<DynamicPicker<T>>>(Self::ID) {
@ -808,6 +808,7 @@ fn handle_event(&mut self, event: &Event, cx: &mut Context) -> EventResult {
picker.options = new_options; picker.options = new_options;
picker.cursor = 0; picker.cursor = 0;
picker.force_score(); picker.force_score();
editor.reset_idle_timer();
})); }));
anyhow::Ok(callback) anyhow::Ok(callback)
}); });