diff options
author | zeertzjq <zeertzjq@outlook.com> | 2023-10-14 19:18:25 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-14 19:18:25 +0800 |
commit | bcda800933f6de09392c3c91e290077952989722 (patch) | |
tree | b4bababb6bb9aa3f80375db4feab2ccffd32c594 /test | |
parent | 99b1163b5ae7a2f199803541c09f3da80547b40c (diff) | |
download | rneovim-bcda800933f6de09392c3c91e290077952989722.tar.gz rneovim-bcda800933f6de09392c3c91e290077952989722.tar.bz2 rneovim-bcda800933f6de09392c3c91e290077952989722.zip |
vim-patch:9.0.2022: getmousepos() returns wrong index for TAB char (#25636)
Problem: When clicking in the middle of a TAB, getmousepos() returns
the column of the next char instead of the TAB.
Solution: Break out of the loop when the vcol to find is inside current
char. Fix invalid memory access when calling virtcol2col() on
an empty line.
closes: vim/vim#13321
https://github.com/vim/vim/commit/b583eda7031b1f6a3469a2537d0c10ca5fa5568e
Diffstat (limited to 'test')
-rw-r--r-- | test/old/testdir/test_cursor_func.vim | 5 | ||||
-rw-r--r-- | test/old/testdir/test_functions.vim | 40 |
2 files changed, 45 insertions, 0 deletions
diff --git a/test/old/testdir/test_cursor_func.vim b/test/old/testdir/test_cursor_func.vim index 65abbf7c85..cf131e8dad 100644 --- a/test/old/testdir/test_cursor_func.vim +++ b/test/old/testdir/test_cursor_func.vim @@ -573,6 +573,11 @@ func Test_virtcol2col() call assert_equal(8, virtcol2col(0, 1, 7)) call assert_equal(8, virtcol2col(0, 1, 8)) + " These used to cause invalid memory access + call setline(1, '') + call assert_equal(0, virtcol2col(0, 1, 1)) + call assert_equal(0, virtcol2col(0, 1, 2)) + let w = winwidth(0) call setline(2, repeat('a', w + 2)) let win_nosbr = win_getid() diff --git a/test/old/testdir/test_functions.vim b/test/old/testdir/test_functions.vim index b27b0be802..6a4d80d94d 100644 --- a/test/old/testdir/test_functions.vim +++ b/test/old/testdir/test_functions.vim @@ -3069,6 +3069,46 @@ func Test_getmousepos() \ line: 1, \ column: 1, \ }, getmousepos()) + call Ntest_setmouse(1, 2) + call assert_equal(#{ + \ screenrow: 1, + \ screencol: 2, + \ winid: win_getid(), + \ winrow: 1, + \ wincol: 2, + \ line: 1, + \ column: 1, + \ }, getmousepos()) + call Ntest_setmouse(1, 8) + call assert_equal(#{ + \ screenrow: 1, + \ screencol: 8, + \ winid: win_getid(), + \ winrow: 1, + \ wincol: 8, + \ line: 1, + \ column: 1, + \ }, getmousepos()) + call Ntest_setmouse(1, 9) + call assert_equal(#{ + \ screenrow: 1, + \ screencol: 9, + \ winid: win_getid(), + \ winrow: 1, + \ wincol: 9, + \ line: 1, + \ column: 2, + \ }, getmousepos()) + call Ntest_setmouse(1, 12) + call assert_equal(#{ + \ screenrow: 1, + \ screencol: 12, + \ winid: win_getid(), + \ winrow: 1, + \ wincol: 12, + \ line: 1, + \ column: 2, + \ }, getmousepos()) call Ntest_setmouse(1, 25) call assert_equal(#{ \ screenrow: 1, |