commit ae98518f6bdbf22a92bd88399deab1642b3721ca from: Mark Jamsek via: Thomas Adam date: Tue Jul 12 08:00:21 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 - 97cb21cdfaeff6052c984dd9a9bbe56f5e2deb60 commit + ae98518f6bdbf22a92bd88399deab1642b3721ca blob - 8c414237565f6f896667f19527083e844f1331eb blob + 073f1d8a7443c9dbbc3b80a2ce3214102db001ba --- tog/tog.c +++ tog/tog.c @@ -969,6 +969,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) @@ -989,6 +991,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; @@ -1024,9 +1028,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; @@ -1198,9 +1202,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; @@ -2402,7 +2406,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;