Commit a026b947176c52261534aa3ad22bdaa6dd10b482

Stefan Sperling 2018-07-12T23:19:04

don't sroll beyond end of file in tog blame view

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
diff --git a/tog/tog.c b/tog/tog.c
index 9e3a9cb..66fdd7e 100644
--- a/tog/tog.c
+++ b/tog/tog.c
@@ -1557,7 +1557,9 @@ show_blame_view(const char *path, struct got_object_id *commit_id,
 				break;
 			case 'j':
 			case KEY_DOWN:
-				if (selected_line < LINES - 2)
+				if (selected_line < LINES - 2 &&
+				    first_displayed_line + selected_line <=
+				    blame.nlines)
 					selected_line++;
 				else if (last_displayed_line < blame.nlines)
 					first_displayed_line++;