aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2025-03-06 08:24:13 +0800
committerGitHub <noreply@github.com>2025-03-06 08:24:13 +0800
commit1a35eb9b568e1d916cf86dfb27c723e788254923 (patch)
tree8ee25036a082a444d3f9af5df8856c194eb5c60e /test
parenta261f602a067c7cb4de39fa6330053c08dcfd5e5 (diff)
downloadrneovim-1a35eb9b568e1d916cf86dfb27c723e788254923.tar.gz
rneovim-1a35eb9b568e1d916cf86dfb27c723e788254923.tar.bz2
rneovim-1a35eb9b568e1d916cf86dfb27c723e788254923.zip
vim-patch:9.1.1175: inconsistent behaviour with exclusive selection and motion commands (#32745)
Problem: inconsistent behaviour with exclusive selection and motion commands (aidancz) Solution: adjust cursor position when selection is exclusive (Jim Zhou) fixes: vim/vim#16278 closes: vim/vim#16784 https://github.com/vim/vim/commit/c8cce711dde2d8abcf0929b3b12c4bfc5547a89d Co-authored-by: Jim Zhou <jimzhouzzy@gmail.com> Co-authored-by: Hirohito Higashi <h.east.727@gmail.com>
Diffstat (limited to 'test')
-rw-r--r--test/old/testdir/test_visual.vim44
1 files changed, 44 insertions, 0 deletions
diff --git a/test/old/testdir/test_visual.vim b/test/old/testdir/test_visual.vim
index 328ac502bf..f5a5970e24 100644
--- a/test/old/testdir/test_visual.vim
+++ b/test/old/testdir/test_visual.vim
@@ -1101,6 +1101,50 @@ func Test_exclusive_selection()
bw!
endfunc
+" Test for inclusive motion in visual mode with 'exclusive' selection
+func Test_inclusive_motion_selection_exclusive()
+ func s:compare_exclu_inclu(line, keys, expected_exclu)
+ let msg = "data: '" . a:line . "' operation: '" . a:keys . "'"
+ call setline(1, a:line)
+ set selection=exclusive
+ call feedkeys(a:keys, 'xt')
+ call assert_equal(a:expected_exclu, getpos('.'), msg)
+ let pos_ex = col('.')
+ set selection=inclusive
+ call feedkeys(a:keys, 'xt')
+ let pos_in = col('.')
+ call assert_equal(1, pos_ex - pos_in, msg)
+ endfunc
+
+ new
+ " Test 'e' motion
+ set selection=exclusive
+ call setline(1, 'eins zwei drei')
+ norm! ggvey
+ call assert_equal('eins', @")
+ call setline(1, 'abc(abc)abc')
+ norm! ggveeed
+ call assert_equal(')abc', getline(1))
+ call setline(1, 'abc(abc)abc')
+ norm! gg3lvey
+ call assert_equal('(abc', @")
+ call s:compare_exclu_inclu('abc(abc)abc', 'ggveee', [0, 1, 8, 0])
+ " Test 'f' motion
+ call s:compare_exclu_inclu('geschwindigkeit', 'ggvfefe', [0, 1, 14, 0])
+ call s:compare_exclu_inclu('loooooooooooong', 'ggv2fo2fo2fo', [0, 1, 8, 0])
+ " Test 't' motion
+ call s:compare_exclu_inclu('geschwindigkeit', 'ggv2te', [0, 1, 13, 0])
+ call s:compare_exclu_inclu('loooooooooooong', 'gglv2to2to2to', [0, 1, 6, 0])
+ " Test ';' motion
+ call s:compare_exclu_inclu('geschwindigkeit', 'ggvfi;;', [0, 1, 15, 0])
+ call s:compare_exclu_inclu('geschwindigkeit', 'ggvti;;', [0, 1, 14, 0])
+ call s:compare_exclu_inclu('loooooooooooong', 'ggv2fo;;', [0, 1, 6, 0])
+ call s:compare_exclu_inclu('loooooooooooong', 'ggvl2to;;', [0, 1, 6, 0])
+ " Clean up
+ set selection&
+ bw!
+endfunc
+
" Test for starting linewise visual with a count.
" This test needs to be run without any previous visual mode. Otherwise the
" count will use the count from the previous visual mode.