aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/nvim/move.c11
-rw-r--r--test/old/testdir/test_normal.vim8
2 files changed, 15 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);
diff --git a/test/old/testdir/test_normal.vim b/test/old/testdir/test_normal.vim
index 7f67dcdeb1..0336e43902 100644
--- a/test/old/testdir/test_normal.vim
+++ b/test/old/testdir/test_normal.vim
@@ -4270,4 +4270,12 @@ func Test_page_cursor_topbot()
bwipe!
endfunc
+" Test for Ctrl-D with long line
+func Test_halfpage_longline()
+ 10new
+ call setline(1, ['long'->repeat(1000), 'short'])
+ exe "norm! \<C-D>"
+ call assert_equal(2, line('.'))
+ bwipe!
+endfunc
" vim: shiftwidth=2 sts=2 expandtab nofoldenable