From 4c476bc872a80bb180bf10c99d7e4295126b67f4 Mon Sep 17 00:00:00 2001
From: Benno Schulenberg <bensberg@justemail.net>
Date: Fri, 28 Oct 2016 11:37:03 +0200
Subject: [PATCH] scrolling: use a comparison that will work also in softwrap
 mode

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

diff --git a/src/move.c b/src/move.c
index e35d66ae..d621e29e 100644
--- a/src/move.c
+++ b/src/move.c
@@ -438,12 +438,10 @@ void do_up(bool scroll_only)
     openfile->current_x = actual_x(openfile->current->data,
 					openfile->placewewant);
 
-    /* If scroll_only is FALSE and if we're on the first line of the
-     * edit window, scroll the edit window up one line if we're in
-     * smooth scrolling mode, or up half a page if we're not.  If
-     * scroll_only is TRUE, scroll the edit window up one line
-     * unconditionally. */
-    if (openfile->current_y == 0 || scroll_only)
+    /* When the cursor was on the first line of the edit window (or when just
+     * scrolling without moving the cursor), scroll the edit window up -- one
+     * line if we're in smooth scrolling mode, and half a page otherwise. */
+    if (openfile->current->next == openfile->edittop || scroll_only)
 	edit_scroll(UPWARD, (ISSET(SMOOTH_SCROLL) || scroll_only) ?
 				1 : editwinrows / 2 + 1);
 
-- 
GitLab