From 6834650570dfec1a811f6ea36451dba1525b1ba5 Mon Sep 17 00:00:00 2001
From: David Lawrence Ramsey <pooka109@gmail.com>
Date: Tue, 16 Aug 2005 03:03:15 +0000
Subject: [PATCH] really fix edit_scroll() breakage

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2996 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
---
 src/winio.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/src/winio.c b/src/winio.c
index d11655ad..6ebe97cb 100644
--- a/src/winio.c
+++ b/src/winio.c
@@ -3560,12 +3560,11 @@ void edit_scroll(scroll_dir direction, ssize_t nlines)
     /* Part 2: nlines is the number of lines in the scrolled region of
      * the edit window that we need to draw. */
 
-    /* If we couldn't scroll up or down all nlines lines, and we're now
-     * at the top or bottom of the file, we need to draw the entire edit
-     * window. */
-    if (i > 0 && ((direction == UP && openfile->edittop ==
-	openfile->fileage) || (direction == DOWN && openfile->current ==
-	openfile->filebot)))
+    /* If the top or bottom line of the file is now visible in the edit
+     * window, we need to draw the entire edit window. */
+    if ((direction == UP && openfile->edittop == openfile->fileage) ||
+	(direction == DOWN && openfile->edittop->lineno + editwinrows -
+	1 >= openfile->filebot->lineno))
 	nlines = editwinrows;
 
     /* If the scrolled region contains only one line, and the line
-- 
GitLab