tweaks: set the target row for smooth scrolling more directly

The function place_the_cursor() assumes that the viewport is up to date,
i.e., that current is in range of edittop.  When uncutting or inserting,
however, place_the_cursor() gets called on the out-of-date viewport
first, and then a screen refresh is scheduled (which would put the
viewport up to date).  This is backwards: the refresh should come before
the cursor placement, and the only reason it works anyway is because the
cap on the number of chunks to move backward papers over the problem by
keeping current_y in screen range regardless.

Fix this properly by simply setting current_y to the bottom row of the
screen instead of calling place_the_cursor().  This value of current_y
is only ever used when in smooth scrolling mode and the insertion (or
paste) pushed the cursor offscreen.  In other situations, this value is
overridden when place_the_cursor() gets called after a screen refresh.

After that fix, the cap on the number of chunks to move backward is no
longer needed.
master
David Lawrence Ramsey 2017-07-20 19:02:16 -05:00 committed by Benno Schulenberg
parent 4d54231967
commit 6f9bb53b2d
3 changed files with 4 additions and 8 deletions

View File

@ -291,8 +291,8 @@ void do_uncut_text(void)
/* Mark the file as modified. */
set_modified();
/* Update current_y to account for the inserted lines. */
place_the_cursor(TRUE);
/* Set the target row for the cursor in case it got pushed offscreen. */
openfile->current_y = editwinrows - 1;
refresh_needed = TRUE;

View File

@ -1188,8 +1188,8 @@ void do_insertfile(void)
openfile->current_x != was_current_x)
set_modified();
/* Update current_y to account for inserted lines. */
place_the_cursor(TRUE);
/* Set the target row for the cursor when pushed offscreen. */
openfile->current_y = editwinrows - 1;
refresh_needed = TRUE;
}

View File

@ -2803,10 +2803,6 @@ int go_back_chunks(int nrows, filestruct **line, size_t *leftedge)
{
int i;
/* Don't move more chunks than the window can hold. */
if (nrows > editwinrows - 1)
nrows = (editwinrows < 2) ? 1 : editwinrows - 1;
#ifndef NANO_TINY
if (ISSET(SOFTWRAP)) {
/* Recede through the requested number of chunks. */