Commit 67409a31c95a35d375588f38a9dc11d5add7a918

Stefan Sperling 2019-05-24T16:10:24

tog: if opening a tree view for a logged file, jump to that file

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
diff --git a/tog/tog.c b/tog/tog.c
index fb469f1..9ff2c0f 100644
--- a/tog/tog.c
+++ b/tog/tog.c
@@ -1468,8 +1468,12 @@ browse_commit_tree(struct tog_view **new_view, int begin_x,
 		if (s->tree != s->root)
 			s->selected++; /* skip '..' */
 
-		if (!S_ISDIR(s->selected_entry->mode))
+		if (!S_ISDIR(s->selected_entry->mode)) {
+			/* Jump to this file's entry. */
+			s->first_displayed_entry = s->selected_entry;
+			s->selected = 0;
 			break;
+		}
 
 		slash = strchr(p, '/');
 		if (slash)