diff options
Diffstat (limited to 'desktop')
-rw-r--r-- | desktop/treeview.c | 36 |
1 files changed, 13 insertions, 23 deletions
diff --git a/desktop/treeview.c b/desktop/treeview.c index 9d3dce54a..02dd7e208 100644 --- a/desktop/treeview.c +++ b/desktop/treeview.c @@ -573,34 +573,24 @@ static bool treeview_walk_internal(struct treeview_node *root, bool full, node->children : NULL; if (next != NULL) { - /* down to children */ + /* Down to children */ node = next; inset += tree_g.step_width; } else { - /* no children */ - next = node->sibling_next; - - if (next != NULL && node != root) { - /* on to next sibling */ - node = next; - } else { - /* no next sibling */ - while (node != root) { - next = node->sibling_next; - - if (next != NULL) { - break; - } - - node = node->parent; - inset -= tree_g.step_width; - } + /* No children. As long as we're not at the root, + * go to next sibling if present, or nearest ancestor + * with a next sibling. */ + + while (node != root && + node->sibling_next == NULL) { + node = node->parent; + inset -= tree_g.step_width; + } - if (node == root) - break; + if (node == root) + break; - node = node->sibling_next; - } + node = node->sibling_next; } assert(node != NULL); |