summaryrefslogtreecommitdiff
path: root/helix-core/src
diff options
context:
space:
mode:
authorBlaž Hrastnik2021-09-07 04:05:53 +0000
committerBlaž Hrastnik2021-09-07 04:05:53 +0000
commitfd36fbdebfa6508699979dc426725cbbc2dbe295 (patch)
treed1e38ef912228993ff029fce58898aefce295079 /helix-core/src
parentfde0a84bbacd2b95ef5f6433f8ee8d4a91817555 (diff)
parent3cbdc057de69b3ffaf1e8b69dea114872d9d128a (diff)
Merge branch 'lsp-async-init'
Diffstat (limited to 'helix-core/src')
-rw-r--r--helix-core/src/indent.rs11
-rw-r--r--helix-core/src/syntax.rs8
2 files changed, 14 insertions, 5 deletions
diff --git a/helix-core/src/indent.rs b/helix-core/src/indent.rs
index f5f36aca..55802059 100644
--- a/helix-core/src/indent.rs
+++ b/helix-core/src/indent.rs
@@ -316,8 +316,12 @@ pub fn suggested_indent_for_pos(
pub fn get_scopes(syntax: Option<&Syntax>, text: RopeSlice, pos: usize) -> Vec<&'static str> {
let mut scopes = Vec::new();
if let Some(syntax) = syntax {
- let byte_start = text.char_to_byte(pos);
- let node = match get_highest_syntax_node_at_bytepos(syntax, byte_start) {
+ let pos = text.char_to_byte(pos);
+ let mut node = match syntax
+ .tree()
+ .root_node()
+ .descendant_for_byte_range(pos, pos)
+ {
Some(node) => node,
None => return scopes,
};
@@ -325,7 +329,8 @@ pub fn get_scopes(syntax: Option<&Syntax>, text: RopeSlice, pos: usize) -> Vec<&
scopes.push(node.kind());
while let Some(parent) = node.parent() {
- scopes.push(parent.kind())
+ scopes.push(parent.kind());
+ node = parent;
}
}
diff --git a/helix-core/src/syntax.rs b/helix-core/src/syntax.rs
index a7a5d022..1afe0e25 100644
--- a/helix-core/src/syntax.rs
+++ b/helix-core/src/syntax.rs
@@ -144,8 +144,12 @@ impl LanguageConfiguration {
&highlights_query,
&injections_query,
&locals_query,
- )
- .unwrap(); // TODO: no unwrap
+ );
+
+ let config = match config {
+ Ok(config) => config,
+ Err(err) => panic!("{}", err),
+ }; // TODO: avoid panic
config.configure(scopes);
Some(Arc::new(config))
}