summaryrefslogtreecommitdiffstats
path: root/src/testdir/test_scroll_opt.vim
diff options
context:
space:
mode:
authorYee Cheng Chin <ychin.git@gmail.com>2022-11-19 12:25:16 +0000
committerBram Moolenaar <Bram@vim.org>2022-11-19 12:25:16 +0000
commit361895d2a15b4b0bbbb4c009261eab5b3d69ebf1 (patch)
tree21c7c932e95563ec43015810b6d007e10f543373 /src/testdir/test_scroll_opt.vim
parentd63a85592cef0ee4f0fec5efe2f8d66b31f01f05 (diff)
patch 9.0.0908: with 'smoothscroll' cursor may end up in wrong positionv9.0.0908
Problem: With 'smoothscroll' cursor may end up in wrong position. Solution: Correct the computation of screen lines. (Yee Cheng Chin, closes #11502)
Diffstat (limited to 'src/testdir/test_scroll_opt.vim')
-rw-r--r--src/testdir/test_scroll_opt.vim26
1 files changed, 25 insertions, 1 deletions
diff --git a/src/testdir/test_scroll_opt.vim b/src/testdir/test_scroll_opt.vim
index 3975a1fe99..d40c650f3c 100644
--- a/src/testdir/test_scroll_opt.vim
+++ b/src/testdir/test_scroll_opt.vim
@@ -246,7 +246,7 @@ func Test_smoothscroll_wrap_long_line()
let lines =<< trim END
vim9script
- setline(1, ['one', 'two', 'Line' .. (' with lots of text'->repeat(30))])
+ setline(1, ['one', 'two', 'Line' .. (' with lots of text'->repeat(30)) .. ' end', 'four'])
set smoothscroll scrolloff=0
normal 3G10|zt
END
@@ -287,6 +287,30 @@ func Test_smoothscroll_wrap_long_line()
call term_sendkeys(buf, "gj")
call term_sendkeys(buf, "\<C-Y>")
call VerifyScreenDump(buf, 'Test_smooth_long_9', {})
+
+ " '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.
+ call term_sendkeys(buf, ":set scrolloff=0\<CR>")
+ call term_sendkeys(buf, "0j")
+ call VerifyScreenDump(buf, 'Test_smooth_long_10', {})
+
+ " Repeat the step and move the cursor down again.
+ " This time, use a shorter long line that is barely long enough to span more
+ " than one window. Note that the cursor is at the bottom this time because
+ " Vim prefers to do so if we are scrolling a few lines only.
+ call term_sendkeys(buf, ":call setline(1, ['one', 'two', 'Line' .. (' with lots of text'->repeat(10)) .. ' end', 'four'])\<CR>")
+ call term_sendkeys(buf, "3Gzt")
+ call term_sendkeys(buf, "j")
+ call VerifyScreenDump(buf, 'Test_smooth_long_11', {})
+
+ " Repeat the step but this time start it when the line is smooth-scrolled by
+ " one line. This tests that the offset calculation is still correct and
+ " still end up scrolling down to the next line with cursor at bottom of
+ " screen.
+ call term_sendkeys(buf, "3Gzt")
+ call term_sendkeys(buf, "\<C-E>j")
+ call VerifyScreenDump(buf, 'Test_smooth_long_12', {})
call StopVimInTerminal(buf)
endfunc