From 6e4ec961013a378362457dbe08954d58a41b9299 Mon Sep 17 00:00:00 2001 From: uncenter Date: Fri, 13 Jun 2025 10:15:40 -0400 Subject: [PATCH 1/3] Highlight Ecma escape sequences (#13762) --- runtime/queries/ecma/highlights.scm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/runtime/queries/ecma/highlights.scm b/runtime/queries/ecma/highlights.scm index fcc47ce11..4b23d66a8 100644 --- a/runtime/queries/ecma/highlights.scm +++ b/runtime/queries/ecma/highlights.scm @@ -235,6 +235,8 @@ (template_string) ] @string +(escape_sequence) @constant.character.escape + (regex) @string.regexp (number) @constant.numeric.integer From b90d8960a865dc5f90576f46c84e96167e0f75d6 Mon Sep 17 00:00:00 2001 From: polyface Date: Fri, 13 Jun 2025 16:20:07 +0200 Subject: [PATCH 2/3] added crystal formatter in languages.toml (#13759) Co-authored-by: polyface --- languages.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/languages.toml b/languages.toml index 105895034..9d7e4be0a 100644 --- a/languages.toml +++ b/languages.toml @@ -648,6 +648,7 @@ comment-token = "#" indent = { tab-width = 2, unit = " " } grammar = "ruby" language-servers = [ "crystalline" ] +formatter = { command = "crystal", args = ["tool", "format", "-"] } [[language]] name = "c-sharp" From fba1a6188a8201cca4e22d3d4e434e45069e49cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20K=C3=B6hnen?= Date: Fri, 13 Jun 2025 16:29:26 +0200 Subject: [PATCH 3/3] Picker: Detect language before rendering preview (#13761) --- helix-term/src/ui/picker.rs | 33 ++++++++++++++-------------- helix-term/src/ui/picker/handlers.rs | 9 ++++---- 2 files changed, 20 insertions(+), 22 deletions(-) diff --git a/helix-term/src/ui/picker.rs b/helix-term/src/ui/picker.rs index 7abdfce84..3f3aaba2b 100644 --- a/helix-term/src/ui/picker.rs +++ b/helix-term/src/ui/picker.rs @@ -585,8 +585,7 @@ impl Picker { // retrieve the `Arc` key. The `path` in scope here is a `&Path` and // we can cheaply clone the key for the preview highlight handler. let (path, preview) = self.preview_cache.get_key_value(path).unwrap(); - if matches!(preview, CachedPreview::Document(doc) if doc.language_config().is_none()) - { + if matches!(preview, CachedPreview::Document(doc) if doc.syntax().is_none()) { helix_event::send_blocking(&self.preview_highlight_handler, path.clone()); } return Some((Preview::Cached(preview), range)); @@ -624,27 +623,27 @@ impl Picker { if content_type.is_binary() { return Ok(CachedPreview::Binary); } - Document::open( + let mut doc = Document::open( &path, None, false, editor.config.clone(), editor.syn_loader.clone(), ) - .map_or( - Err(std::io::Error::new( - std::io::ErrorKind::NotFound, - "Cannot open document", - )), - |doc| { - // Asynchronously highlight the new document - helix_event::send_blocking( - &self.preview_highlight_handler, - path.clone(), - ); - Ok(CachedPreview::Document(Box::new(doc))) - }, - ) + .or(Err(std::io::Error::new( + std::io::ErrorKind::NotFound, + "Cannot open document", + )))?; + let loader = editor.syn_loader.load(); + if let Some(language_config) = doc.detect_language_config(&loader) { + doc.language = Some(language_config); + // Asynchronously highlight the new document + helix_event::send_blocking( + &self.preview_highlight_handler, + path.clone(), + ); + } + Ok(CachedPreview::Document(Box::new(doc))) } else { Err(std::io::Error::new( std::io::ErrorKind::NotFound, diff --git a/helix-term/src/ui/picker/handlers.rs b/helix-term/src/ui/picker/handlers.rs index 9a3af9b32..eabfac0c7 100644 --- a/helix-term/src/ui/picker/handlers.rs +++ b/helix-term/src/ui/picker/handlers.rs @@ -66,16 +66,15 @@ impl AsyncHook return; }; - if doc.language_config().is_some() { + if doc.syntax().is_some() { return; } - let loader = editor.syn_loader.load(); - let Some(language_config) = doc.detect_language_config(&loader) else { + let Some(language) = doc.language_config().map(|config| config.language()) else { return; }; - let language = language_config.language(); - doc.language = Some(language_config); + + let loader = editor.syn_loader.load(); let text = doc.text().clone(); tokio::task::spawn_blocking(move || {