aboutsummaryrefslogtreecommitdiff
path: root/helix-core
diff options
context:
space:
mode:
Diffstat (limited to 'helix-core')
-rw-r--r--helix-core/src/object.rs9
1 files changed, 4 insertions, 5 deletions
diff --git a/helix-core/src/object.rs b/helix-core/src/object.rs
index b06f4144..d2d4fe70 100644
--- a/helix-core/src/object.rs
+++ b/helix-core/src/object.rs
@@ -2,12 +2,11 @@ use crate::{Range, RopeSlice, Selection, Syntax};
use tree_sitter::Node;
pub fn expand_selection(syntax: &Syntax, text: RopeSlice, selection: Selection) -> Selection {
- select_node_impl(syntax, text, selection, |descendant, from, to| {
- if descendant.start_byte() == from && descendant.end_byte() == to {
- descendant.parent()
- } else {
- Some(descendant)
+ select_node_impl(syntax, text, selection, |mut node, from, to| {
+ while node.start_byte() == from && node.end_byte() == to {
+ node = node.parent()?;
}
+ Some(node)
})
}