aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2024-05-02 19:33:54 +0800
committerGitHub <noreply@github.com>2024-05-02 19:33:54 +0800
commitc4627676f9a3bc88760c54bc6f1dc38904f064d2 (patch)
tree6c49387d7c1edcf808ab6f07d97e88fe9468c060 /test
parentd26943a6e185dea23077d41b4c81281e12be3997 (diff)
downloadrneovim-c4627676f9a3bc88760c54bc6f1dc38904f064d2.tar.gz
rneovim-c4627676f9a3bc88760c54bc6f1dc38904f064d2.tar.bz2
rneovim-c4627676f9a3bc88760c54bc6f1dc38904f064d2.zip
vim-patch:9.1.0388: cursor() and getregion() don't handle v:maxcol well (#28602)
Problem: cursor() and getregion() don't handle v:maxcol well. Solution: Add special handling for v:maxcol like setpos() does. (zeertzjq) closes: vim/vim#14698 https://github.com/vim/vim/commit/2ffdae79487cb7e323383eda9ae96c2e9d1625bd
Diffstat (limited to 'test')
-rw-r--r--test/old/testdir/test_virtualedit.vim22
-rw-r--r--test/old/testdir/test_visual.vim3
2 files changed, 25 insertions, 0 deletions
diff --git a/test/old/testdir/test_virtualedit.vim b/test/old/testdir/test_virtualedit.vim
index 6448c7a3e3..8d9656e058 100644
--- a/test/old/testdir/test_virtualedit.vim
+++ b/test/old/testdir/test_virtualedit.vim
@@ -709,5 +709,27 @@ func Test_virtualedit_replace_after_tab()
bwipe!
endfunc
+" Test that setpos('.') and cursor() behave the same for v:maxcol
+func Test_virtualedit_set_cursor_pos_maxcol()
+ new
+ set virtualedit=all
+
+ call setline(1, 'foobar')
+ exe "normal! V\<Esc>"
+ call assert_equal([0, 1, 1, 0], getpos("'<"))
+ call assert_equal([0, 1, v:maxcol, 0], getpos("'>"))
+ let pos = getpos("'>")
+
+ call cursor(1, 1)
+ call setpos('.', pos)
+ call assert_equal([0, 1, 7, 0], getpos('.'))
+
+ call cursor(1, 1)
+ call cursor(pos[1:])
+ call assert_equal([0, 1, 7, 0], getpos('.'))
+
+ set virtualedit&
+ bwipe!
+endfunc
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/test/old/testdir/test_visual.vim b/test/old/testdir/test_visual.vim
index 864ccd428d..bc84fde98e 100644
--- a/test/old/testdir/test_visual.vim
+++ b/test/old/testdir/test_visual.vim
@@ -1702,6 +1702,9 @@ func Test_visual_getregion()
\ "'a"->getpos()->getregion(getpos("'a"), {'type': 'V' }))
call assert_equal(['one', 'two'],
\ "."->getpos()->getregion(getpos("'a"), {'type': "\<c-v>" }))
+ call feedkeys("\<ESC>jVj\<ESC>", 'tx')
+ call assert_equal(['two', 'three'], getregion(getpos("'<"), getpos("'>")))
+ call assert_equal(['two', 'three'], getregion(getpos("'>"), getpos("'<")))
#" Using List
call cursor(1, 1)