Don't return invisible nodes from ts_node_find_for_range

This commit is contained in:
Max Brunsfeld 2015-08-14 20:10:09 -07:00
parent 507b7aef00
commit d70a7227a1
2 changed files with 16 additions and 2 deletions

View file

@ -118,7 +118,7 @@ TSNode ts_node_child(TSNode this, size_t child_index) {
}
TSNode ts_node_find_for_range(TSNode this, size_t min, size_t max) {
TSNode node = this;
TSNode node = this, last_visible_node = this;
bool did_descend = true;
while (did_descend) {
did_descend = false;
@ -131,13 +131,15 @@ TSNode ts_node_find_for_range(TSNode this, size_t min, size_t max) {
break;
if (position.chars + child->padding.chars + child->size.chars > max) {
node = ts_node_make(child, position);
if (ts_tree_is_visible(child))
last_visible_node = node;
did_descend = true;
}
position = ts_length_add(position, ts_tree_total_size(child));
}
}
return node;
return last_visible_node;
}
TSNode ts_node_find_for_pos(TSNode this, size_t position) {