commit - 6f99ebb8a88fd2d2dae1309ef67512f9910a5568
commit + 07b55e752e53f5437e0f7f55593fdd550e4a16da
blob - ca141f1783f91240ba9507acac4b2edaf8d77cfe
blob + 363c498b7ab411a2bfeb6783f3a68ab2c108c990
--- tog/tog.c
+++ tog/tog.c
return err;
}
+
+static void
+scroll_up(struct commit_queue_entry **first_displayed_entry, int n,
+ struct commit_queue *commits)
+{
+ struct commit_queue_entry *entry;
+ int nscrolled = 0;
+
+ entry = TAILQ_FIRST(commits);
+ if (*first_displayed_entry == entry)
+ return;
+ entry = *first_displayed_entry;
+ while (entry && nscrolled < n) {
+ entry = TAILQ_PREV(entry, commit_queue, entry);
+ if (entry) {
+ *first_displayed_entry = entry;
+ nscrolled++;
+ }
+ }
+}
+
static const struct got_error *
show_log_view(struct got_object_id *start_id, struct got_repository *repo)
{
selected--;
if (selected > 0)
break;
- /* scroll down if there are more children */
- entry = TAILQ_FIRST(&commits);
- if (first_displayed_entry == entry)
- break;
- first_displayed_entry =
- TAILQ_PREV(first_displayed_entry,
- commit_queue, entry);
+ scroll_up(&first_displayed_entry, 1, &commits);
break;
case 'j':
case KEY_DOWN: