aboutsummaryrefslogtreecommitdiff
path: root/helix-core/src/indent.rs
diff options
context:
space:
mode:
authorDmitry Sharshakov2021-09-25 20:14:59 +0000
committerDmitry Sharshakov2021-09-25 20:14:59 +0000
commitbf53aff27d2d90b41bab01f4d628f0bd9fbcd589 (patch)
tree568d745540acd05ae7526e8a3eed7ee8e31e3cea /helix-core/src/indent.rs
parent413e477dc2d4792596f99979140d2879ec3d4f4f (diff)
parentdf55eaae69d0388de26448e82f9ded483fca2f44 (diff)
Merge branch 'master' into debug
Diffstat (limited to 'helix-core/src/indent.rs')
-rw-r--r--helix-core/src/indent.rs12
1 files changed, 9 insertions, 3 deletions
diff --git a/helix-core/src/indent.rs b/helix-core/src/indent.rs
index 4b74aa7a..1f32d038 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;
}
}
@@ -449,6 +454,7 @@ where
highlight_config: OnceCell::new(),
config: None,
//
+ injection_regex: None,
roots: vec![],
comment_token: None,
auto_format: false,