aboutsummaryrefslogtreecommitdiff
path: root/helix-core
diff options
context:
space:
mode:
authorcossonleo2021-10-28 05:31:44 +0000
committerBlaž Hrastnik2021-10-29 01:04:12 +0000
commitbefecc8a9a087436a9dbc6942e328646c3391874 (patch)
tree82b889100b4b57fc603e1103922689c52eb3ca8e /helix-core
parentf1d339919f4299d570bb6f7fcf5fcc58c0f281cf (diff)
select smaller range on some case
Diffstat (limited to 'helix-core')
-rw-r--r--helix-core/src/object.rs9
1 files changed, 7 insertions, 2 deletions
diff --git a/helix-core/src/object.rs b/helix-core/src/object.rs
index d9558dd8..717c5994 100644
--- a/helix-core/src/object.rs
+++ b/helix-core/src/object.rs
@@ -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,
};