Merge pull request #97157 from pafuent/fixing_tree_item_get_prev_wrap

Fix `TreeItem` `get_prev*` methods when `p_wrap` is `true`
This commit is contained in:
Thaddeus Crews
2024-10-25 13:03:42 -05:00
2 changed files with 135 additions and 11 deletions

View File

@ -961,19 +961,17 @@ TreeItem *TreeItem::_get_prev_in_tree(bool p_wrap, bool p_include_invisible) {
if (!prev_item) {
current = current->parent;
if (current == tree->root && tree->hide_root) {
return nullptr;
} else if (!current) {
if (p_wrap) {
current = this;
TreeItem *temp = get_next_visible();
while (temp) {
current = temp;
temp = temp->get_next_visible();
}
} else {
if (!current || (current == tree->root && tree->hide_root)) {
if (!p_wrap) {
return nullptr;
}
// Wrap around to the last visible item.
current = this;
TreeItem *temp = get_next_visible();
while (temp) {
current = temp;
temp = temp->get_next_visible();
}
}
} else {
current = prev_item;