Download raw body.
tog: fix resize failure to populate log view commits
If resizing a log view while on the _last_ loaded commit on the bottom
edge of the screen, some of the new lines are not populated.
repro:
$ tog # 80x24
23j # move down to the last commit
*increase terminal height to ~30 lines then reduce back to 80x24*
~5j # move down to the _last_ commit
*increase terminal height to ~33 lines*
Most of the new lines are empty.
We call request_log_commits() from view_resize()--but only when the view
has a child view. The fix simply moves this check, so that we always
call request_log_commits() if the terminal height has been increased,
irrespective of whether a child view exists.
diff /home/mark/src/git/got-current
commit - d2587c5f95c6edb51ccc8d4abfac838b58f3a463
path + /home/mark/src/git/got-current
blob - 97ac0690a9232815bb10bc4a237246e2ec53e069
file + tog/tog.c
--- tog/tog.c
+++ tog/tog.c
@@ -875,24 +875,6 @@ view_resize(struct tog_view *view)
show_panel(view->child->panel);
}
/*
- * Request commits if terminal height was increased in a log
- * view so we have enough commits loaded to populate the view.
- */
- if (view->type == TOG_VIEW_LOG && dif > 0) {
- struct tog_log_view_state *ts = &view->state.log;
-
- if (ts->commits.ncommits < ts->selected_entry->idx +
- view->lines - ts->selected) {
- view->nscrolled = ts->selected_entry->idx +
- view->lines - ts->selected -
- ts->commits.ncommits + dif;
- err = request_log_commits(view);
- if (err)
- return err;
- }
- }
-
- /*
* XXX This is ugly and needs to be moved into the above
* logic but "works" for now and my attempts at moving it
* break either 'tab' or 'F' key maps in horizontal splits.
@@ -915,6 +897,24 @@ view_resize(struct tog_view *view)
} else if (view->parent == NULL)
ncols = COLS;
+ /*
+ * Request commits if terminal height was increased in a log
+ * view so we have enough commits loaded to populate the view.
+ */
+ if (view->type == TOG_VIEW_LOG && dif > 0) {
+ struct tog_log_view_state *ts = &view->state.log;
+
+ if (ts->commits.ncommits < ts->selected_entry->idx +
+ view->lines - ts->selected) {
+ view->nscrolled = ts->selected_entry->idx +
+ view->lines - ts->selected -
+ ts->commits.ncommits + dif + 1;
+ err = request_log_commits(view);
+ if (err)
+ return err;
+ }
+ }
+
if (wresize(view->window, nlines, ncols) == ERR)
return got_error_from_errno("wresize");
if (replace_panel(view->panel, view->window) == ERR)
--
Mark Jamsek <fnc.bsdbox.org>
GPG: F2FF 13DE 6A06 C471 CA80 E6E2 2930 DC66 86EE CF68
tog: fix resize failure to populate log view commits