mirror of
https://github.com/helix-editor/helix.git
synced 2024-11-22 09:26:19 +04:00
Fix edge-case in tree-sitter expand_selection selection command (#2877)
Co-authored-by: Triton171 <triton0171@gmail.com>
This commit is contained in:
parent
18435899b2
commit
e1b1a5ebc0
@ -2,12 +2,11 @@
|
||||
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)
|
||||
})
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user