Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'helix-term/src/ui/picker/handlers.rs')
| -rw-r--r-- | helix-term/src/ui/picker/handlers.rs | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/helix-term/src/ui/picker/handlers.rs b/helix-term/src/ui/picker/handlers.rs index eabfac0c..040fffa8 100644 --- a/helix-term/src/ui/picker/handlers.rs +++ b/helix-term/src/ui/picker/handlers.rs @@ -66,24 +66,27 @@ impl<T: 'static + Send + Sync, D: 'static + Send + Sync> AsyncHook return; }; - if doc.syntax().is_some() { + if doc.language_config().is_some() { return; } - let Some(language) = doc.language_config().map(|config| config.language()) else { + let Some(language_config) = doc.detect_language_config(&editor.syn_loader.load()) + else { return; }; - - let loader = editor.syn_loader.load(); + doc.language = Some(language_config.clone()); let text = doc.text().clone(); + let loader = editor.syn_loader.clone(); tokio::task::spawn_blocking(move || { - let syntax = match helix_core::Syntax::new(text.slice(..), language, &loader) { - Ok(syntax) => syntax, - Err(err) => { - log::info!("highlighting picker preview failed: {err}"); - return; - } + let Some(syntax) = language_config + .highlight_config(&loader.load().scopes()) + .and_then(|highlight_config| { + helix_core::Syntax::new(text.slice(..), highlight_config, loader) + }) + else { + log::info!("highlighting picker item failed"); + return; }; job::dispatch_blocking(move |editor, compositor| { |