From 373e3b880f01eb04950136f1055c6a79ada9a805 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg <bensberg@telfort.nl> Date: Sun, 18 Mar 2018 15:58:46 +0100 Subject: [PATCH] scrolling: first move the cursor before pushing current chunk offscreen When the cursor is on the first or last row of the edit window, and thus Scroll-Down or Scroll-Up would push it offscreen, first move the cursor away from the edge row and then scroll. This fixes https://savannah.gnu.org/bugs/?53376. --- src/move.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/move.c b/src/move.c index 92044f41..eb80157c 100644 --- a/src/move.c +++ b/src/move.c @@ -529,20 +529,22 @@ void do_scroll_up(void) if (openfile->edittop->prev == NULL && openfile->firstcolumn == 0) return; - edit_scroll(BACKWARD); - if (openfile->current_y == editwinrows - 1) do_up(); + + edit_scroll(BACKWARD); } /* Scroll down one line or chunk without scrolling the cursor. */ void do_scroll_down(void) { - if (openfile->current->next != NULL || openfile->current_y > 0) - edit_scroll(FORWARD); - if (openfile->current_y == 0) do_down(); + + if (openfile->edittop->next != NULL || + chunk_for(openfile->firstcolumn, openfile->edittop) < + number_of_chunks_in(openfile->edittop)) + edit_scroll(FORWARD); } #endif -- GitLab