move.c: dont invalidate viewport when no scroll happened

This commit is contained in:
Rom Grk 2020-10-25 02:25:22 -04:00
parent a1596f0b0b
commit d2a38dab80
2 changed files with 18 additions and 6 deletions

View File

@ -1020,7 +1020,7 @@ void textpos2screenpos(win_T *wp, pos_T *pos, int *rowp, int *scolp,
/*
* Scroll the current window down by "line_count" logical lines. "CTRL-Y"
*/
void
bool
scrolldown (
long line_count,
int byfold /* true: count a closed fold as one line */
@ -1095,17 +1095,21 @@ scrolldown (
foldAdjustCursor();
coladvance(curwin->w_curswant);
}
return moved;
}
/*
* Scroll the current window up by "line_count" logical lines. "CTRL-E"
*/
void
bool
scrollup (
long line_count,
int byfold /* true: count a closed fold as one line */
)
{
linenr_T topline = curwin->w_topline;
linenr_T botline = curwin->w_botline;
if ((byfold && hasAnyFolding(curwin))
|| curwin->w_p_diff) {
// count each sequence of folded lines as one logical line
@ -1148,6 +1152,12 @@ scrollup (
~(VALID_WROW|VALID_WCOL|VALID_CHEIGHT|VALID_CROW|VALID_VIRTCOL);
coladvance(curwin->w_curswant);
}
bool moved =
topline != curwin->w_topline ||
botline != curwin->w_botline;
return moved;
}
/*

View File

@ -4117,10 +4117,10 @@ void scroll_redraw(int up, long count)
int prev_topfill = curwin->w_topfill;
linenr_T prev_lnum = curwin->w_cursor.lnum;
if (up)
scrollup(count, true);
else
bool moved = up ?
scrollup(count, true) :
scrolldown(count, true);
if (get_scrolloff_value()) {
// Adjust the cursor position for 'scrolloff'. Mark w_topline as
// valid, otherwise the screen jumps back at the end of the file.
@ -4152,7 +4152,9 @@ void scroll_redraw(int up, long count)
}
if (curwin->w_cursor.lnum != prev_lnum)
coladvance(curwin->w_curswant);
curwin->w_viewport_invalid = true;
// XXX: can `moved` be used to prevent other work here?
if (moved)
curwin->w_viewport_invalid = true;
redraw_later(VALID);
}