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
parent
4d54231967
commit
6f9bb53b2d
|
@ -291,8 +291,8 @@ void do_uncut_text(void)
|
||||||
/* Mark the file as modified. */
|
/* Mark the file as modified. */
|
||||||
set_modified();
|
set_modified();
|
||||||
|
|
||||||
/* Update current_y to account for the inserted lines. */
|
/* Set the target row for the cursor in case it got pushed offscreen. */
|
||||||
place_the_cursor(TRUE);
|
openfile->current_y = editwinrows - 1;
|
||||||
|
|
||||||
refresh_needed = TRUE;
|
refresh_needed = TRUE;
|
||||||
|
|
||||||
|
|
|
@ -1188,8 +1188,8 @@ void do_insertfile(void)
|
||||||
openfile->current_x != was_current_x)
|
openfile->current_x != was_current_x)
|
||||||
set_modified();
|
set_modified();
|
||||||
|
|
||||||
/* Update current_y to account for inserted lines. */
|
/* Set the target row for the cursor when pushed offscreen. */
|
||||||
place_the_cursor(TRUE);
|
openfile->current_y = editwinrows - 1;
|
||||||
|
|
||||||
refresh_needed = TRUE;
|
refresh_needed = TRUE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2803,10 +2803,6 @@ int go_back_chunks(int nrows, filestruct **line, size_t *leftedge)
|
||||||
{
|
{
|
||||||
int i;
|
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
|
#ifndef NANO_TINY
|
||||||
if (ISSET(SOFTWRAP)) {
|
if (ISSET(SOFTWRAP)) {
|
||||||
/* Recede through the requested number of chunks. */
|
/* Recede through the requested number of chunks. */
|
||||||
|
|
Loading…
Reference in New Issue