Fix crash w/ goto_previous_sibling when parent node has leading extra child (#4472)
* Fix crash w/ goto_previous_sibling when parent node has leading extra child Co-authored-by: Smit Barmase <heysmitbarmase@gmail.com> Co-authored-by: Smit Barmase <heysmitbarmase@gmail.com> * Fix lint Co-authored-by: Smit Barmase <heysmitbarmase@gmail.com> --------- Co-authored-by: Smit Barmase <heysmitbarmase@gmail.com>
This commit is contained in:
parent
06537fda83
commit
f91255a201
7 changed files with 90 additions and 46 deletions
|
|
@ -129,14 +129,18 @@ static inline bool ts_tree_cursor_child_iterator_previous(
|
|||
};
|
||||
*visible = ts_subtree_visible(*child);
|
||||
bool extra = ts_subtree_extra(*child);
|
||||
if (!extra && self->alias_sequence) {
|
||||
*visible |= self->alias_sequence[self->structural_child_index];
|
||||
self->structural_child_index--;
|
||||
}
|
||||
|
||||
self->position = length_backtrack(self->position, ts_subtree_padding(*child));
|
||||
self->child_index--;
|
||||
|
||||
if (!extra && self->alias_sequence) {
|
||||
*visible |= self->alias_sequence[self->structural_child_index];
|
||||
if (self->child_index > 0) {
|
||||
self->structural_child_index--;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// unsigned can underflow so compare it to child_count
|
||||
if (self->child_index < self->parent.ptr->child_count) {
|
||||
Subtree previous_child = ts_subtree_children(self->parent)[self->child_index];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue