diff --git a/common/menu.c b/common/menu.c index 257526cd..40b97ede 100644 --- a/common/menu.c +++ b/common/menu.c @@ -504,9 +504,11 @@ static size_t print_tree(size_t offset, size_t window, const char *shift, size_t if (max_len == NULL) { max_len = &dummy_max_len; } + if (!level) { + *max_len = 0; + } if (shift == NULL) { no_print = true; - *max_len = 0; } for (;;) { @@ -813,7 +815,7 @@ refresh: print_tree(tree_offset, terms[0]->rows - 10, NULL, 0, 0, selected_entry, menu_tree, &selected_menu_entry, &max_tree_len); - size_t tree_prefix_len = terms[0]->cols / 2 - max_tree_len / 2; + size_t tree_prefix_len = terms[0]->cols / 2 - DIV_ROUNDUP(max_tree_len, 2); if (!serial) tree_prefix_len += strlen("│") - 1; char *tree_prefix = ext_mem_alloc(tree_prefix_len); memset(tree_prefix, ' ', tree_prefix_len);