mirror of
https://github.com/helix-editor/helix.git
synced 2024-09-20 08:05:10 +03:00
select smaller range on some case
This commit is contained in:
parent
f1d339919f
commit
befecc8a9a
@ -13,8 +13,13 @@ pub fn expand_selection(syntax: &Syntax, text: RopeSlice, selection: &Selection)
|
||||
let parent = match tree
|
||||
.root_node()
|
||||
.descendant_for_byte_range(from, to)
|
||||
.and_then(|node| node.parent())
|
||||
{
|
||||
.and_then(|node| {
|
||||
if node.child_count() == 0 || (node.start_byte() == from && node.end_byte() == to) {
|
||||
node.parent()
|
||||
} else {
|
||||
Some(node)
|
||||
}
|
||||
}) {
|
||||
Some(parent) => parent,
|
||||
None => return range,
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user