better interactivity while loading commits in tog log view
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
diff --git a/tog/tog.c b/tog/tog.c
index 64e4bd0..22c411b 100644
--- a/tog/tog.c
+++ b/tog/tog.c
@@ -1256,34 +1256,30 @@ scroll_down(struct tog_view *view,
if (*last_displayed_entry == NULL)
return NULL;
- do {
- pentry = TAILQ_NEXT(*last_displayed_entry, entry);
- if (pentry == NULL && !*log_complete) {
- (*commits_needed)++;
-
- if (nscrolled == 0) {
- /* Redraw screen for "loading..." message. */
- err = show_log_view(view);
- if (err)
- return err;
- update_panels();
- doupdate();
- }
-
- while (*commits_needed > 0) {
- int errcode;
- errcode = pthread_cond_signal(need_commits);
- if (errcode)
- return got_error_set_errno(errcode);
- errcode = pthread_mutex_unlock(&tog_mutex);
- if (errcode)
- return got_error_set_errno(errcode);
- pthread_yield();
- errcode = pthread_mutex_lock(&tog_mutex);
- if (errcode)
- return got_error_set_errno(errcode);
- }
+ pentry = TAILQ_NEXT(*last_displayed_entry, entry);
+ if (pentry == NULL && !*log_complete) {
+ int errcode;
+ if (*commits_needed > 0)
+ return NULL;
+ (*commits_needed) = maxscroll;
+ errcode = pthread_cond_signal(need_commits);
+ if (errcode)
+ return got_error_set_errno(errcode);
+ errcode = pthread_mutex_unlock(&tog_mutex);
+ if (errcode)
+ return got_error_set_errno(errcode);
+ pthread_yield();
+ errcode = pthread_mutex_lock(&tog_mutex);
+ if (errcode)
+ return got_error_set_errno(errcode);
+ if (*commits_needed > 0) {
+ /* Thread is not done yet; lose a key press
+ * and let the user retry... */
+ return NULL;
}
+ }
+
+ do {
pentry = TAILQ_NEXT(*last_displayed_entry, entry);
if (pentry == NULL)
break;