Skip to content

Commit

Permalink
Simplify TextObject cell init
Browse files Browse the repository at this point in the history
  • Loading branch information
sudormrfbin committed Oct 6, 2021
1 parent 5ea3f6f commit a652a1e
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions helix-core/src/syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,14 +211,12 @@ impl LanguageConfiguration {

pub fn textobject_query(&self) -> Option<&TextObjectQuery> {
self.textobject_query
.get_or_init(|| {
let language = self.language_id.to_ascii_lowercase();
let query = read_query(&language, "textobjects.scm");
self.highlight_config
.get()
.and_then(|config| config.as_ref().map(|c| c.language))
.and_then(move |lang| Query::new(lang, &query).ok())
.map(|query| TextObjectQuery { query })
.get_or_init(|| -> Option<TextObjectQuery> {
let lang_name = self.language_id.to_ascii_lowercase();
let query_text = read_query(&lang_name, "textobjects.scm");
let lang = self.highlight_config.get()?.as_ref()?.language;
let query = Query::new(lang, &query_text).ok()?;
Some(TextObjectQuery { query })
})
.as_ref()
}
Expand Down

0 comments on commit a652a1e

Please sign in to comment.