commit 27187d45e7a2f096a06777e5ffde690e3c049490 from: Mark Jamsek date: Mon Jul 11 14:31:49 2022 UTC tog: only request commits when child hsplit increases Fix bug introduced in 3c1dfe12b3 that fails to properly populate child log views due to incorrect request_log_commits() calls: (1) when increasing the bottom hsplit in a ref/log splitscreen; and (2) when reopening a child log view after closing a resized child log view: $ TOG_VIEW_SPLIT_MODE=h tog ref return # open log view in bottom split 4+ # increase log (child/bottom) split *new log lines are not populated* q # close log view return *commits are not loaded* ok stsp@ commit - d9a7ab538a90fea0c81ac4c31fd196123baf4fd4 commit + 27187d45e7a2f096a06777e5ffde690e3c049490 blob - 03896eaec6ac32378d42edec34772acd9108d8bf blob + 2a08545196a8a55276ca860ed3c40e5d659d2134 --- tog/tog.c +++ tog/tog.c @@ -965,6 +965,8 @@ view_resize_split(struct tog_view *view, int resize) v->resize = v->child->resize = resize; /* lock for resize event */ if (view->mode == TOG_VIEW_SPLIT_HRZN) { + int y = v->child->begin_y; + if (v->child->resized_y) v->child->begin_y = v->child->resized_y; if (view->parent) @@ -985,6 +987,8 @@ view_resize_split(struct tog_view *view, int resize) if (err) return err; v->child->resized_y = v->child->begin_y; + if (y > v->child->begin_y) /* split increased */ + v->child->nscrolled = y - v->child->begin_y; } else { if (v->child->resized_x) v->child->begin_x = v->child->resized_x; @@ -1020,9 +1024,9 @@ view_resize_split(struct tog_view *view, int resize) return err; } - if (v->type == TOG_VIEW_LOG) + if (v->type == TOG_VIEW_LOG && v->nscrolled) err = request_log_commits(v); - else if (v->child->type == TOG_VIEW_LOG) + else if (v->child->type == TOG_VIEW_LOG && v->child->nscrolled) err = request_log_commits(v->child); v->resize = v->child->resize = 0; @@ -1194,9 +1198,9 @@ switch_split(struct tog_view *view) offset_selection_up(v); offset_selection_up(v->child); } - if (v->type == TOG_VIEW_LOG) + if (v->type == TOG_VIEW_LOG && v->nscrolled) err = request_log_commits(v); - else if (v->child->type == TOG_VIEW_LOG) + else if (v->child->type == TOG_VIEW_LOG && v->child->nscrolled) err = request_log_commits(v->child); return err; @@ -2398,7 +2402,7 @@ request_log_commits(struct tog_view *view) struct tog_log_view_state *state = &view->state.log; const struct got_error *err = NULL; - state->thread_args.commits_needed = view->nscrolled; + state->thread_args.commits_needed += view->nscrolled; err = trigger_log_thread(view, 1); view->nscrolled = 0;