aboutsummaryrefslogtreecommitdiff
path: root/helix-core/src/object.rs
diff options
context:
space:
mode:
Diffstat (limited to 'helix-core/src/object.rs')
-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,
};