@@ -161,6 +161,27 @@ impl<T: Item> FilePicker<T> {
161161 self . preview_cache . insert ( path. to_owned ( ) , preview) ;
162162 Preview :: Cached ( & self . preview_cache [ path] )
163163 }
164+
165+ fn handle_idle_timeout ( & mut self , cx : & mut Context ) -> EventResult {
166+ // Try to find a document in the cache
167+ let doc = self
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) ,
172+ _ => None ,
173+ } ) ;
174+
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) ;
180+ }
181+ }
182+
183+ EventResult :: Consumed ( None )
184+ }
164185}
165186
166187impl < T : Item + ' static > Component for FilePicker < T > {
@@ -261,6 +282,9 @@ impl<T: Item + 'static> Component for FilePicker<T> {
261282 }
262283
263284 fn handle_event ( & mut self , event : & Event , ctx : & mut Context ) -> EventResult {
285+ if let Event :: IdleTimeout = event {
286+ return self . handle_idle_timeout ( ctx) ;
287+ }
264288 // TODO: keybinds for scrolling preview
265289 self . picker . handle_event ( event, ctx)
266290 }
@@ -505,6 +529,9 @@ impl<T: Item + 'static> Component for Picker<T> {
505529 compositor. last_picker = compositor. pop ( ) ;
506530 } ) ) ) ;
507531
532+ // So that idle timeout retriggers
533+ cx. editor . reset_idle_timer ( ) ;
534+
508535 match key_event {
509536 shift ! ( Tab ) | key ! ( Up ) | ctrl ! ( 'p' ) => {
510537 self . move_by ( 1 , Direction :: Backward ) ;
0 commit comments