softwrap: account for firstcolumn when scrolling up a line

In do_up() when scroll_only is TRUE, if we're at the top of the screen
in softwrap mode, it's not enough to check that edittop is on fileage.
We also need to check that firstcolumn is zero.

In do_up() when scroll_only is FALSE, if we're at the top of the screen
in softwrap mode, current_y should be zero.  This is equivalent to how,
in do_down() when scroll_only is FALSE, current_y is (editwinrows - 1)
at the bottom of the screen in softwrap mode.  Since edittop can now
be partially scrolled off the screen even when it takes up the entire
screen, checking for edittop's being equal to openfile->current->next
there no longer applies.
master
David Lawrence Ramsey 2017-01-31 19:23:21 -06:00 committed by Benno Schulenberg
parent 2f6c8987ea
commit 93152d3258
1 changed files with 3 additions and 2 deletions

View File

@ -459,7 +459,8 @@ void do_up(bool scroll_only)
size_t target_column = openfile->placewewant;
/* When just scrolling and the top of the file is onscreen, get out. */
if (scroll_only && openfile->edittop == openfile->fileage)
if (scroll_only && openfile->edittop == openfile->fileage &&
openfile->firstcolumn == 0)
return;
#ifndef NANO_TINY
@ -480,7 +481,7 @@ void do_up(bool 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)
if (openfile->current_y == 0 || scroll_only)
edit_scroll(UPWARD, (ISSET(SMOOTH_SCROLL) || scroll_only) ?
1 : editwinrows / 2 + 1);