select smaller range on some case

pull/933/head
cossonleo 3 years ago committed by Blaž Hrastnik
parent f1d339919f
commit befecc8a9a

@ -13,8 +13,13 @@ pub fn expand_selection(syntax: &Syntax, text: RopeSlice, selection: &Selection)
let parent = match tree let parent = match tree
.root_node() .root_node()
.descendant_for_byte_range(from, to) .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, Some(parent) => parent,
None => return range, None => return range,
}; };

Loading…
Cancel
Save