commit 68e4cf9bea15e2ac33224f8b96d7f5ff58ac6e77
parent 3cf57de2bdf4311ebc7e8348ead2bca7cadb3904
Author: Jochen Sprickerhof <git@jochen.sprickerhof.de>
Date:   Thu, 23 Apr 2020 22:26:28 +0200
Fix setting bottom pointer while scrolling
Diffstat:
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git 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;
 				}