aboutsummaryrefslogtreecommitdiff
path: root/helix-core
diff options
context:
space:
mode:
authorMichael Davis2022-04-18 15:14:48 +0000
committerGitHub2022-04-18 15:14:48 +0000
commit4e877de54d4ad79cf5dafca6642f63ee1a8d5ae4 (patch)
tree5918b1eb6b8f9741eecf62d8dcbc1d77b694708a /helix-core
parent449d1dfdfbf56ace564182dc85802e57b8494975 (diff)
Fix Golang textobject queries (#2153)
* log textobject query construction errors The current behavior is that invalid queries are discarded silently which makes it difficult to debug invalid textobjects (either invalid syntax or an update may have come through that changed the valid set of nodes). * fix golang textobject query `method_spec_list` used to be a named node but was removed (I think for Helix, it was when updated to pull in the support for generics). Instead of a named node for the list of method specs we have a bunch of `method_spec` children nodes now. We can match on the set of them with a `+` wildcard. Example go for this query: type Shape interface { area() float64 perimeter() float64 } Which is parsed as: (source_file (type_declaration (type_spec name: (type_identifier) type: (interface_type (method_spec name: (field_identifier) parameters: (parameter_list) result: (type_identifier)) (method_spec name: (field_identifier) parameters: (parameter_list) result: (type_identifier))))))
Diffstat (limited to 'helix-core')
-rw-r--r--helix-core/src/syntax.rs4
1 files changed, 3 insertions, 1 deletions
diff --git a/helix-core/src/syntax.rs b/helix-core/src/syntax.rs
index 72b0e956..905b3347 100644
--- a/helix-core/src/syntax.rs
+++ b/helix-core/src/syntax.rs
@@ -413,7 +413,9 @@ impl LanguageConfiguration {
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()?;
+ let query = Query::new(lang, &query_text)
+ .map_err(|e| log::error!("Failed to parse textobjects.scm queries: {}", e))
+ .ok()?;
Some(TextObjectQuery { query })
})
.as_ref()