From 384332d08c73c2268f610393f1fbff82ba518b81 Mon Sep 17 00:00:00 2001
From: David Lawrence Ramsey <pooka109@gmail.com>
Date: Sun, 26 Mar 2017 18:50:55 -0500
Subject: [PATCH] display: make PageUp/PageDown use the correct beginning of
 the viewport

When typing PageUp or PageDOwn in non-smooth-scrolling mode, the cursor
should be placed at the start of the top line of the edit window.  This
means that, when the line at edittop is partially scrolled offscreen,
the cursor should be placed at openfile->firstcolumn, not at zero.

This fixes https://savannah.gnu.org/bugs/?50645.
Reported-by: David Lawrence Ramsey <pooka109@gmail.com>
---
 src/move.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/move.c b/src/move.c
index 4b1c8301..75372d2c 100644
--- a/src/move.c
+++ b/src/move.c
@@ -60,7 +60,8 @@ void do_page_up(void)
      * beginning of the top line of the edit window, as Pico does. */
     if (!ISSET(SMOOTH_SCROLL)) {
 	openfile->current = openfile->edittop;
-	openfile->placewewant = openfile->current_y = 0;
+	openfile->placewewant = target_column = openfile->firstcolumn;
+	openfile->current_y = 0;
     }
 
     mustmove = (editwinrows < 3) ? 1 : editwinrows - 2;
@@ -99,7 +100,8 @@ void do_page_down(void)
      * beginning of the top line of the edit window, as Pico does. */
     if (!ISSET(SMOOTH_SCROLL)) {
 	openfile->current = openfile->edittop;
-	openfile->placewewant = openfile->current_y = 0;
+	openfile->placewewant = target_column = openfile->firstcolumn;
+	openfile->current_y = 0;
     }
 
     mustmove = (editwinrows < 3) ? 1 : editwinrows - 2;
-- 
GitLab