From 06ffcfaf403be022c92649611f633e7feba7f52c Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Tue, 8 Aug 2017 21:52:54 +0200 Subject: [PATCH] display: catch all cases where the cursor can be pushed offscreen Discarding (in commit 6f9bb53b) the cap on the number of chunks to move backwards had as an unforeseen side effect that the screen can fail to scroll when the cursor is somehow pushed offscreen. Fix this by setting the target row (for smooth scrolling) always to the bottom row of the edit window when nano notices that the cursor has gone offscreen. This fixes https://savannah.gnu.org/bugs/?51676. Reported-by: David Lawrence Ramsey --- src/cut.c | 3 --- src/files.c | 3 --- src/winio.c | 1 + 3 files changed, 1 insertion(+), 6 deletions(-) diff --git a/src/cut.c b/src/cut.c index 8c141b94..ec514b3b 100644 --- a/src/cut.c +++ b/src/cut.c @@ -290,9 +290,6 @@ void do_uncut_text(void) /* Mark the file as modified. */ set_modified(); - /* Set the target row for the cursor in case it got pushed offscreen. */ - openfile->current_y = editwinrows - 1; - refresh_needed = TRUE; #ifndef DISABLE_COLOR diff --git a/src/files.c b/src/files.c index 1e4e4603..7ba166da 100644 --- a/src/files.c +++ b/src/files.c @@ -1185,9 +1185,6 @@ void do_insertfile(void) openfile->current_x != was_current_x) set_modified(); - /* Set the target row for the cursor when pushed offscreen. */ - openfile->current_y = editwinrows - 1; - refresh_needed = TRUE; } diff --git a/src/winio.c b/src/winio.c index 31da9387..c5f1fe26 100644 --- a/src/winio.c +++ b/src/winio.c @@ -3216,6 +3216,7 @@ void edit_refresh(void) fprintf(stderr, "edit-refresh: line = %ld, edittop = %ld and editwinrows = %d\n", (long)openfile->current->lineno, (long)openfile->edittop->lineno, editwinrows); #endif + openfile->current_y = editwinrows - 1; adjust_viewport((focusing || !ISSET(SMOOTH_SCROLL)) ? CENTERING : STATIONARY); }