From 9cf980700c305db8f3040c8b0e157a0ea56d1752 Mon Sep 17 00:00:00 2001
From: Benno Schulenberg <bensberg@justemail.net>
Date: Mon, 27 Mar 2017 19:39:10 +0200
Subject: [PATCH] moving: don't try to redraw lines that have gone outside the
 viewport

When scrolling backward, it is not just the bottom line of the screen
that doesn't need to be redrawn: also the line /before/ the top line
doesn't need a redraw.  Mutatis mutandis for scrolling forward.

This fixes https://savannah.gnu.org/bugs/?50657.
---
 src/move.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/move.c b/src/move.c
index ebafa82b..de3b533f 100644
--- a/src/move.c
+++ b/src/move.c
@@ -489,7 +489,7 @@ void do_up(bool scroll_only)
 				1 : editwinrows / 2 + 1);
 
     /* If the lines weren't already redrawn, see if they need to be. */
-    if (openfile->current_y > 0) {
+    if (openfile->current_y > 0 && openfile->current_y < editwinrows - 1) {
 	/* Redraw the prior line if it's not actually the same line as the
 	 * current one (which it might be in softwrap mode, if we moved just
          * one chunk) and the line was horizontally scrolled. */
@@ -545,7 +545,7 @@ void do_down(bool scroll_only)
 				1 : editwinrows / 2 + 1);
 
     /* If the lines weren't already redrawn, see if they need to be. */
-    if (openfile->current_y < editwinrows - 1) {
+    if (openfile->current_y > 0 && openfile->current_y < editwinrows - 1) {
 	/* Redraw the prior line if it's not actually the same line as the
 	 * current one (which it might be in softwrap mode, if we moved just
          * one chunk) and the line was horizontally scrolled. */
-- 
GitLab