commit 68e4cf9bea15e2ac33224f8b96d7f5ff58ac6e77
Author:     Jochen Sprickerhof <g...@jochen.sprickerhof.de>
AuthorDate: Thu Apr 23 22:26:28 2020 +0200
Commit:     Jochen Sprickerhof <g...@jochen.sprickerhof.de>
CommitDate: Thu Apr 23 22:26:28 2020 +0200

    Fix setting bottom pointer while scrolling

diff --git a/scroll.c b/scroll.c
index 5b09893..f8de6c0 100644
--- a/scroll.c
+++ b/scroll.c
@@ -246,8 +246,6 @@ addline(char *buf, size_t size)
        line->buf = earealloc(NULL, size);
        memcpy(line->buf, buf, size);
 
-       bottom = line;
-
        TAILQ_INSERT_HEAD(&head, line, entries);
 }
 
@@ -536,6 +534,13 @@ main(int argc, char *argv[])
 
                                if (*c == '\n') {
                                        addline(buf, pos);
+                                       /* only advance bottom if scroll is */
+                                       /* at the end of the scroll back */
+                                       if (bottom == NULL ||
+                                           TAILQ_PREV(bottom, tailhead,
+                                             entries) == TAILQ_FIRST(&head))
+                                               bottom = TAILQ_FIRST(&head);
+
                                        memset(buf, 0, size);
                                        pos = 0;
                                }

Reply via email to