Skip to content

Commit

Permalink
Respect injections in movement::move_parent_node_end
Browse files Browse the repository at this point in the history
  • Loading branch information
the-mikedavis authored and archseer committed Jan 28, 2024
1 parent 8b6565c commit 035b8ea
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
7 changes: 1 addition & 6 deletions helix-core/src/movement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!(
Expand Down
6 changes: 6 additions & 0 deletions helix-core/src/syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 035b8ea

Please sign in to comment.