@@ -2,12 +2,11 @@ use crate::{Range, RopeSlice, Selection, Syntax};
22use tree_sitter::Node;
33
44pub fn expand_selection(syntax: &Syntax, text: RopeSlice, selection: Selection) -> Selection {
5− select_node_impl(syntax, text, selection, |descendant, from, to| {
6− if descendant.start_byte() == from && descendant.end_byte() == to {
7− descendant.parent()
8− } else {
9− Some(descendant)
5+ select_node_impl(syntax, text, selection, |mut node, from, to| {
6+ while node.start_byte() == from && node.end_byte() == to {
7+ node = node.parent()?;
108 }
9+ Some(node)
1110 })
1211}
1312