diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/move.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/nvim/move.c b/src/nvim/move.c index 66667cecc4..b07bc33b17 100644 --- a/src/nvim/move.c +++ b/src/nvim/move.c @@ -2412,8 +2412,10 @@ static int get_scroll_overlap(Direction dir) } } -/// Scroll "count" lines with 'smoothscroll' in direction "dir". -static bool scroll_with_sms(Direction dir, int count) +/// Scroll "count" lines with 'smoothscroll' in direction "dir". Return true +/// when scrolling happened. Adjust "curscount" for scrolling different amount +/// of lines when 'smoothscroll' is disabled. +static bool scroll_with_sms(Direction dir, int count, int *curscount) { int prev_sms = curwin->w_p_sms; colnr_T prev_skipcol = curwin->w_skipcol; @@ -2435,6 +2437,7 @@ static bool scroll_with_sms(Direction dir, int count) while (curwin->w_skipcol > 0 && curwin->w_topline < curbuf->b_ml.ml_line_count) { scroll_redraw(fixdir == FORWARD, 1); + *curscount += (fixdir == dir ? 1 : -1); } } curwin->w_p_sms = prev_sms; @@ -2482,7 +2485,7 @@ int pagescroll(Direction dir, int count, bool half) // (Try to) scroll the window unless already at the end of the buffer. if (count > 0) { - nochange = scroll_with_sms(dir, count); + nochange = scroll_with_sms(dir, count, &curscount); curwin->w_cursor.lnum = prev_lnum; curwin->w_cursor.col = prev_col; curwin->w_curswant = prev_curswant; @@ -2500,7 +2503,7 @@ int pagescroll(Direction dir, int count, bool half) // Scroll [count] times 'window' or current window height lines. count *= ((ONE_WINDOW && p_window > 0 && p_window < Rows - 1) ? MAX(1, (int)p_window - 2) : get_scroll_overlap(dir)); - nochange = scroll_with_sms(dir, count); + nochange = scroll_with_sms(dir, count, &count); // Place cursor at top or bottom of window. validate_botline(curwin); |