From fa025f0ca3cb2bcd20d541564a4024f06cf036fe Mon Sep 17 00:00:00 2001
From: David Lawrence Ramsey <pooka109@gmail.com>
Date: Thu, 19 Jan 2017 01:28:16 -0600
Subject: [PATCH] display: limit an optimization to non-softwrap mode

Not drawing a line on a row if we're on the top row and scrolled down,
or if we're on the bottom row and scrolled up, will only work properly
if the line on that row takes up only that row.  The latter might not
be the case in softwrap mode: if the line occupies multiple chunks and
begins on that row -- in that case none of the chunks would be drawn.
---
 src/winio.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/src/winio.c b/src/winio.c
index 3c068366..c3dd8d34 100644
--- a/src/winio.c
+++ b/src/winio.c
@@ -2929,12 +2929,14 @@ void edit_scroll(scroll_dir direction, int nrows)
     }
 
     /* Draw new lines on any blank rows before or inside the scrolled region.
-     * If we scrolled down and we're on the top row, or if we scrolled up and
-     * we're on the bottom row, the row won't be blank, so we don't need to
-     * draw it unless the mark is on or we're not on the first "page". */
+     * If we're not in softwrap mode, we can optimize one case: if we scrolled
+     * forward and we're on the top row, or if we scrolled backward and we're
+     * on the bottom row, the row won't be blank, so we don't need to draw it
+     * unless the mark is on or we're not on the first "page". */
     for (i = nrows; i > 0 && line != NULL; i--) {
-	if ((i == nrows && direction == DOWNWARD) ||
-			(i == 1 && direction == UPWARD)) {
+	if (!ISSET(SOFTWRAP) &&
+		((i == 1 && direction == UPWARD) ||
+		(i == nrows && direction == DOWNWARD))) {
 	    if (line_needs_update(openfile->placewewant, 0))
 		update_line(line, (line == openfile->current) ?
 			openfile->current_x : 0);
-- 
GitLab