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
diff --git a/tog/tog.c b/tog/tog.c
index feaac17..7a8da01 100644
--- a/tog/tog.c
+++ b/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 '..' */
-
- 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;
- }
+ s->first_displayed_entry = s->selected_entry = te;
+
+ if (!S_ISDIR(got_tree_entry_get_mode(s->selected_entry)))
+ break; /* jump to this file's entry */
slash = strchr(p, '/');
if (slash)