@@ -161,6 +161,27 @@ impl<T: Item> FilePicker<T> {
161 self.preview_cache.insert(path.to_owned(), preview);
161 self.preview_cache.insert(path.to_owned(), preview);
162 Preview::Cached(&self.preview_cache[path])
162 Preview::Cached(&self.preview_cache[path])
165+ fn handle_idle_timeout(&mut self, cx: &mut Context) -> EventResult {
166+ // Try to find a document in the cache
168+ .current_file(cx.editor)
169+ .and_then(|(path, _range)| self.preview_cache.get_mut(&path))
170+ .and_then(|cache| match cache {
171+ CachedPreview::Document(doc) => Some(doc),
175+ // Then attempt to highlight it if it has no language set
176+ if let Some(doc) = doc {
177+ if doc.language_config().is_none() {
178+ let loader = cx.editor.syn_loader.clone();
179+ doc.detect_language(loader);
183+ EventResult::Consumed(None)
166impl<T: Item + 'static> Component for FilePicker<T> {
187impl<T: Item + 'static> Component for FilePicker<T> {
@@ -261,6 +282,9 @@ impl<T: Item + 'static> Component for FilePicker<T> {
263 fn handle_event(&mut self, event: &Event, ctx: &mut Context) -> EventResult {
284 fn handle_event(&mut self, event: &Event, ctx: &mut Context) -> EventResult {
285+ if let Event::IdleTimeout = event {
286+ return self.handle_idle_timeout(ctx);
264 // TODO: keybinds for scrolling preview
288 // TODO: keybinds for scrolling preview
265 self.picker.handle_event(event, ctx)
289 self.picker.handle_event(event, ctx)
@@ -505,6 +529,9 @@ impl<T: Item + 'static> Component for Picker<T> {
505 compositor.last_picker = compositor.pop();
529 compositor.last_picker = compositor.pop();
532+ // So that idle timeout retriggers
533+ cx.editor.reset_idle_timer();
508 match key_event {
535 match key_event {
509 shift!(Tab) | key!(Up) | ctrl!('p') => {
536 shift!(Tab) | key!(Up) | ctrl!('p') => {
510 self.move_by(1, Direction::Backward);
537 self.move_by(1, Direction::Backward);