Commit e0d42f609a25f032fe7b71d540dc343013c0a92b

Stefan Sperling 2018-07-22T13:34:59

fix display of selected commit id in tog log view header

diff --git a/tog/tog.c b/tog/tog.c
index 2bda090..445f746 100644
--- a/tog/tog.c
+++ b/tog/tog.c
@@ -498,6 +498,17 @@ draw_commits(struct commit_queue_entry **last,
 	char *id_str, *header;
 	wchar_t *wline;
 
+	entry = first;
+	ncommits = 0;
+	while (entry) {
+		if (ncommits == selected_idx) {
+			*selected = entry;
+			break;
+		}
+		entry = TAILQ_NEXT(entry, entry);
+		ncommits++;
+	}
+
 	err = got_object_id_str(&id_str, (*selected)->id);
 	if (err)
 		return err;
@@ -536,10 +547,8 @@ draw_commits(struct commit_queue_entry **last,
 	while (entry) {
 		if (ncommits >= limit - 1)
 			break;
-		if (ncommits == selected_idx) {
+		if (ncommits == selected_idx)
 			wstandout(tog_log_view.window);
-			*selected = entry;
-		}
 		err = draw_commit(entry->commit, entry->id);
 		if (ncommits == selected_idx)
 			wstandend(tog_log_view.window);