From 6825e195099de6e4eab64e26a230cf8a9c9521b7 Mon Sep 17 00:00:00 2001 From: wojciechkepka Date: Sat, 19 Jun 2021 13:52:28 +0200 Subject: [PATCH] Only reconfiure highlights when setting theme --- helix-core/src/syntax.rs | 19 +++++++++---------- helix-view/src/editor.rs | 2 +- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/helix-core/src/syntax.rs b/helix-core/src/syntax.rs index 78623fd60..81b6d5a05 100644 --- a/helix-core/src/syntax.rs +++ b/helix-core/src/syntax.rs @@ -172,19 +172,18 @@ impl LanguageConfiguration { } } - pub fn highlight_config(&self, scopes: &[String]) -> Option> { - if let Some(config) = self.highlight_config.get() { - if let Some(config) = config { - config.configure(scopes); - } - config.clone() - } else { - self.highlight_config - .get_or_init(|| self.initialize_highlight(scopes)) - .clone() + pub fn reconfigure(&self, scopes: &[String]) { + if let Some(Some(config)) = self.highlight_config.get() { + config.configure(scopes); } } + pub fn highlight_config(&self, scopes: &[String]) -> Option> { + self.highlight_config + .get_or_init(|| self.initialize_highlight(scopes)) + .clone() + } + pub fn is_highlight_initialized(&self) -> bool { self.highlight_config.get().is_some() } diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs index 83d5cbf67..35a547adc 100644 --- a/helix-view/src/editor.rs +++ b/helix-view/src/editor.rs @@ -85,7 +85,7 @@ impl Editor { .language_configs_iter() .filter(|cfg| cfg.is_highlight_initialized()) { - config.highlight_config(scopes); + config.reconfigure(scopes); } self.theme = theme;