From 87a6d4e73615e17559b99afa065799a38fe6c39e Mon Sep 17 00:00:00 2001 From: Blaž Hrastnik Date: Wed, 24 Feb 2021 16:07:39 +0900 Subject: minor: Simplify some code. --- helix-core/src/indent.rs | 2 +- helix-core/src/syntax.rs | 13 +++++-------- 2 files changed, 6 insertions(+), 9 deletions(-) (limited to 'helix-core/src') diff --git a/helix-core/src/indent.rs b/helix-core/src/indent.rs index 68d5d7b0..ec0460d5 100644 --- a/helix-core/src/indent.rs +++ b/helix-core/src/indent.rs @@ -293,7 +293,7 @@ where let language_config = crate::syntax::LOADER .language_config_for_scope("source.rust") .unwrap(); - let highlight_config = language_config.highlight_config(&[]).unwrap().unwrap(); + let highlight_config = language_config.highlight_config(&[]).unwrap(); let syntax = Syntax::new(&state.doc, highlight_config.clone()); let text = state.doc.slice(..); diff --git a/helix-core/src/syntax.rs b/helix-core/src/syntax.rs index 32974e11..0f6b7319 100644 --- a/helix-core/src/syntax.rs +++ b/helix-core/src/syntax.rs @@ -27,12 +27,9 @@ pub struct LanguageConfiguration { } impl LanguageConfiguration { - pub fn highlight_config( - &self, - scopes: &[String], - ) -> Result>, anyhow::Error> { + pub fn highlight_config(&self, scopes: &[String]) -> Option> { self.highlight_config - .get_or_try_init(|| { + .get_or_init(|| { // let name = get_language_name(&self.language_id); let highlights_query = @@ -46,7 +43,7 @@ impl LanguageConfiguration { let locals_query = ""; if highlights_query.is_empty() { - Ok(None) + None } else { let language = get_language(self.language_id); let mut config = HighlightConfiguration::new( @@ -57,10 +54,10 @@ impl LanguageConfiguration { ) .unwrap(); // TODO: no unwrap config.configure(&scopes); - Ok(Some(Arc::new(config))) + Some(Arc::new(config)) } }) - .map(Option::as_ref) + .clone() } pub fn scope(&self) -> &str { -- cgit v1.2.3-70-g09d2