Skip to content

Commit

Permalink
Fix edge-case in tree-sitter expand_selection selection command (#2877)
Browse files Browse the repository at this point in the history
Co-authored-by: Triton171 <[email protected]>
  • Loading branch information
Triton171 and Triton171 authored Jun 25, 2022
1 parent 1843589 commit e1b1a5e
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions helix-core/src/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@ use crate::{Range, RopeSlice, Selection, Syntax};
use tree_sitter::Node;

pub fn expand_selection(syntax: &Syntax, text: RopeSlice, selection: Selection) -> Selection {
select_node_impl(syntax, text, selection, |descendant, from, to| {
if descendant.start_byte() == from && descendant.end_byte() == to {
descendant.parent()
} else {
Some(descendant)
select_node_impl(syntax, text, selection, |mut node, from, to| {
while node.start_byte() == from && node.end_byte() == to {
node = node.parent()?;
}
Some(node)
})
}

Expand Down

0 comments on commit e1b1a5e

Please sign in to comment.