aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/nvim/move.c5
-rw-r--r--test/functional/legacy/scroll_opt_spec.lua9
-rw-r--r--test/old/testdir/test_scroll_opt.vim7
3 files changed, 12 insertions, 9 deletions
diff --git a/src/nvim/move.c b/src/nvim/move.c
index 2bae811e6d..a6c87b641a 100644
--- a/src/nvim/move.c
+++ b/src/nvim/move.c
@@ -1465,7 +1465,10 @@ void adjust_skipcol(void)
bool scrolled = false;
validate_cheight();
- if (curwin->w_cline_height == curwin->w_height) {
+ if (curwin->w_cline_height == curwin->w_height
+ // w_cline_height may be capped at w_height, check there aren't
+ // actually more lines.
+ && plines_win(curwin, curwin->w_cursor.lnum, false) <= curwin->w_height) {
// the line just fits in the window, don't scroll
reset_skipcol(curwin);
return;
diff --git a/test/functional/legacy/scroll_opt_spec.lua b/test/functional/legacy/scroll_opt_spec.lua
index 6c8ca2cf97..31d851f571 100644
--- a/test/functional/legacy/scroll_opt_spec.lua
+++ b/test/functional/legacy/scroll_opt_spec.lua
@@ -494,14 +494,7 @@ describe('smoothscroll', function()
]])
-- 'scrolloff' set to 2, scrolling down, cursor moves screen line up
feed('<C-E>gj<C-Y>')
- screen:expect([[
- <<<ots of text with lots of text with lo|
- ts of text with lots of text with lots o|
- f text wi^th lots of text with lots of te|
- xt with lots of text with lots of text w|
- ith lots of text with lots of text with |
- |
- ]])
+ screen:expect_unchanged()
-- 'scrolloff' set to 0, move cursor down one line. Cursor should move properly,
-- and since this is a really long line, it will be put on top of the screen.
exec('set scrolloff=0')
diff --git a/test/old/testdir/test_scroll_opt.vim b/test/old/testdir/test_scroll_opt.vim
index c8d0f51384..af46773ebf 100644
--- a/test/old/testdir/test_scroll_opt.vim
+++ b/test/old/testdir/test_scroll_opt.vim
@@ -498,6 +498,13 @@ func Test_smoothscroll_cursor_scrolloff()
exe "normal 20h"
call s:check_col_calc(1, 4, 61)
+ " cursor on last line, "gk" should not cause a scroll
+ set scrolloff=0
+ normal G0
+ call s:check_col_calc(1, 7, 1)
+ normal gk
+ call s:check_col_calc(1, 6, 101)
+
bwipe!
endfunc