commit 9a1d514689bb6e57bb47e4c13630ba38bd650a39 from: Christian Weisgerber date: Fri Nov 27 15:46:36 2020 UTC fix entry selection when moving to the parent in tog's tree view The tree view attempts to keep the scroll position of an already visited parent directory intact. If we start out by viewing a subtree and then move up, the scroll position of the parent isn't actually available since the parent tree was never nagivated by the user. In this case tree_view_walk_path() has to fill in some values. The only parent entry we know about in this case is the one which was traversed to reach the child. The best we can do is to lock the parent's scroll position such that the traversed child entry appears at the top of the list if moving up to the parent's view. If we then navigate down again and return, the parent's scroll position will start to be retained and restored properly. Analysis and draft patch by stsp, initial report and simpler fix by yours truly. ok stsp commit - 16aeacf7088dcd3cd5e654af46a3015cecf41426 commit + 9a1d514689bb6e57bb47e4c13630ba38bd650a39 blob - feaac17d0e83e59b9ef24e80a5f347f16db2f891 blob + 7a8da014ea57dd3e28bf67cd12619ae6389b3918 --- tog/tog.c +++ tog/tog.c @@ -1875,17 +1875,10 @@ tree_view_walk_path(struct tog_tree_view_state *s, break; } free(te_name); - s->selected_entry = te; - s->selected = got_tree_entry_get_index(te); - if (s->tree != s->root) - s->selected++; /* skip '..' */ + s->first_displayed_entry = s->selected_entry = te; - if (!S_ISDIR(got_tree_entry_get_mode(s->selected_entry))) { - /* Jump to this file's entry. */ - s->first_displayed_entry = s->selected_entry; - s->selected = 0; - break; - } + if (!S_ISDIR(got_tree_entry_get_mode(s->selected_entry))) + break; /* jump to this file's entry */ slash = strchr(p, '/'); if (slash)