select smaller range on some case
This commit is contained in:
parent
f1d339919f
commit
befecc8a9a
1 changed files with 7 additions and 2 deletions
|
@ -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 a new issue