diff options
author | Luuk van Baal <luukvbaal@gmail.com> | 2023-04-27 17:51:47 +0200 |
---|---|---|
committer | Luuk van Baal <luukvbaal@gmail.com> | 2023-05-02 13:11:47 +0200 |
commit | a2f3855291a59254346545f9699084fe4fece31f (patch) | |
tree | 3215823577c97a86caa081ac19e438a3955f8634 /test | |
parent | 5e4df766f6e428659221f8eae144e9ed18574f8d (diff) | |
download | rneovim-a2f3855291a59254346545f9699084fe4fece31f.tar.gz rneovim-a2f3855291a59254346545f9699084fe4fece31f.tar.bz2 rneovim-a2f3855291a59254346545f9699084fe4fece31f.zip |
vim-patch:9.0.0893: 'smoothscroll' cursor calculations wrong when 'number' is set
Problem: 'smoothscroll' cursor calculations wrong when 'number' is set.
Solution: Correct the code that computes the width. (closes vim/vim#11492)
https://github.com/vim/vim/commit/01ee52bab6041450095c53f9469b1b266a7e3d4d
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/functional/legacy/scroll_opt_spec.lua | 4 | ||||
-rw-r--r-- | test/old/testdir/test_scroll_opt.vim | 66 |
2 files changed, 68 insertions, 2 deletions
diff --git a/test/functional/legacy/scroll_opt_spec.lua b/test/functional/legacy/scroll_opt_spec.lua index 42d8f31d3c..8f0286771a 100644 --- a/test/functional/legacy/scroll_opt_spec.lua +++ b/test/functional/legacy/scroll_opt_spec.lua @@ -279,8 +279,8 @@ describe('smoothscroll', function() ]]) exec('call DoRel()') screen:expect([[ - 2<<<ong text very long text very lon^g te| - xt very long text very long text ver| + 2<<<ong text very long text very long te| + ^xt very long text very long text ver| y long text very long text very long| text very long text very long text | 1 three | diff --git a/test/old/testdir/test_scroll_opt.vim b/test/old/testdir/test_scroll_opt.vim index 423cba76bf..c3600ab4a7 100644 --- a/test/old/testdir/test_scroll_opt.vim +++ b/test/old/testdir/test_scroll_opt.vim @@ -325,5 +325,71 @@ func Test_smoothscroll_one_long_line() call StopVimInTerminal(buf) endfunc +" Test that if the current cursor is on a smooth scrolled line, we correctly +" reposition it. Also check that we don't miscalculate the values by checking +" the consistency between wincol() and col('.') as they are calculated +" separately in code. +func Test_smoothscroll_cursor_position() + call NewWindow(10, 20) + setl smoothscroll wrap + call setline(1, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") + + func s:check_col_calc(win_col, win_line, buf_col) + call assert_equal(a:win_col, wincol()) + call assert_equal(a:win_line, winline()) + call assert_equal(a:buf_col, col('.')) + endfunc + + call s:check_col_calc(1, 1, 1) + exe "normal \<C-E>" + + " Move down another line to avoid blocking the <<< display + call s:check_col_calc(1, 2, 41) + exe "normal \<C-Y>" + call s:check_col_calc(1, 3, 41) + normal ggg$ + exe "normal \<C-E>" + + " Move down only 1 line when we are out of the range of the <<< display + call s:check_col_calc(20, 1, 40) + exe "normal \<C-Y>" + call s:check_col_calc(20, 2, 40) + normal gg + + " Test number, where we have indented lines + setl number + call s:check_col_calc(5, 1, 1) + exe "normal \<C-E>" + call s:check_col_calc(5, 2, 33) + exe "normal \<C-Y>" + call s:check_col_calc(5, 3, 33) + normal ggg$ + exe "normal \<C-E>" + call s:check_col_calc(20, 1, 32) + exe "normal \<C-Y>" + call s:check_col_calc(20, 2, 32) + normal gg + + " Test number + showbreak, so test that the additional indentation works + setl number showbreak=+++ + call s:check_col_calc(5, 1, 1) + exe "normal \<C-E>" + call s:check_col_calc(8, 2, 30) + exe "normal \<C-Y>" + call s:check_col_calc(8, 3, 30) + normal gg + + " Test number + cpo+=n mode, where wrapped lines aren't indented + setl number cpo+=n showbreak= + call s:check_col_calc(5, 1, 1) + exe "normal \<C-E>" + call s:check_col_calc(1, 2, 37) + exe "normal \<C-Y>" + call s:check_col_calc(1, 3, 37) + normal gg + + bwipeout! +endfunc + " vim: shiftwidth=2 sts=2 expandtab |