aboutsummaryrefslogtreecommitdiff
path: root/helix-core/src
diff options
context:
space:
mode:
authorMichael Davis2024-01-25 19:33:37 +0000
committerBlaž Hrastnik2024-01-28 09:13:33 +0000
commit035b8eabdbad02bdcf4f254162623f14767e62de (patch)
treefe1628e2e11c03970318e2d3208b81804d26af14 /helix-core/src
parent8b6565c83924e7ef9176ae4611ec368fbf75ab8a (diff)
Respect injections in movement::move_parent_node_end
Diffstat (limited to 'helix-core/src')
-rw-r--r--helix-core/src/movement.rs7
-rw-r--r--helix-core/src/syntax.rs6
2 files changed, 7 insertions, 6 deletions
diff --git a/helix-core/src/movement.rs b/helix-core/src/movement.rs
index 6c4f3f53..54eb02fd 100644
--- a/helix-core/src/movement.rs
+++ b/helix-core/src/movement.rs
@@ -573,16 +573,11 @@ pub fn move_parent_node_end(
dir: Direction,
movement: Movement,
) -> Selection {
- let tree = syntax.tree();
-
selection.transform(|range| {
let start_from = text.char_to_byte(range.from());
let start_to = text.char_to_byte(range.to());
- let mut node = match tree
- .root_node()
- .named_descendant_for_byte_range(start_from, start_to)
- {
+ let mut node = match syntax.named_descendant_for_byte_range(start_from, start_to) {
Some(node) => node,
None => {
log::debug!(
diff --git a/helix-core/src/syntax.rs b/helix-core/src/syntax.rs
index a403e7cc..24de1a33 100644
--- a/helix-core/src/syntax.rs
+++ b/helix-core/src/syntax.rs
@@ -1352,6 +1352,12 @@ impl Syntax {
self.layers[container_id].tree()
}
+ pub fn named_descendant_for_byte_range(&self, start: usize, end: usize) -> Option<Node<'_>> {
+ self.tree_for_byte_range(start, end)
+ .root_node()
+ .named_descendant_for_byte_range(start, end)
+ }
+
pub fn descendant_for_byte_range(&self, start: usize, end: usize) -> Option<Node<'_>> {
self.tree_for_byte_range(start, end)
.root_node()