diff src/testdir/test_visual.vim @ 19613:9c15be376631 v8.2.0363

patch 8.2.0363: some Normal mode commands not tested Commit: https://github.com/vim/vim/commit/f5f1e10d0d39890298cdf27f664d466c8872b87e Author: Bram Moolenaar <Bram@vim.org> Date: Sun Mar 8 05:13:15 2020 +0100 patch 8.2.0363: some Normal mode commands not tested Problem: Some Normal mode commands not tested. Solution: Add more tests. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/5746)
author Bram Moolenaar <Bram@vim.org>
date Sun, 08 Mar 2020 05:15:04 +0100
parents 67fbe280a502
children f70a3c1000bb
line wrap: on
line diff
--- a/src/testdir/test_visual.vim
+++ b/src/testdir/test_visual.vim
@@ -659,7 +659,6 @@ func Test_linewise_select_mode()
   exe "normal GkkgH\<Del>"
   call assert_equal(['', 'b', 'c'], getline(1, '$'))
 
-
   " linewise select mode: delete middle two lines
   call deletebufline('', 1, '$')
   call append('$', ['a', 'b', 'c'])
@@ -681,6 +680,15 @@ func Test_linewise_select_mode()
   bwipe!
 endfunc
 
+" Test for blockwise select mode (g CTRL-H)
+func Test_blockwise_select_mode()
+  new
+  call setline(1, ['foo', 'bar'])
+  call feedkeys("g\<BS>\<Right>\<Down>mm", 'xt')
+  call assert_equal(['mmo', 'mmr'], getline(1, '$'))
+  close!
+endfunc
+
 func Test_visual_mode_put()
   new
 
@@ -908,4 +916,57 @@ func Test_star_register()
   close!
 endfunc
 
+" Test for using visual mode maps in select mode
+func Test_select_mode_map()
+  new
+  vmap <buffer> <F2> 3l
+  call setline(1, 'Test line')
+  call feedkeys("gh\<F2>map", 'xt')
+  call assert_equal('map line', getline(1))
+
+  vmap <buffer> <F2> ygV
+  call feedkeys("0gh\<Right>\<Right>\<F2>cwabc", 'xt')
+  call assert_equal('abc line', getline(1))
+
+  vmap <buffer> <F2> :<C-U>let v=100<CR>
+  call feedkeys("gggh\<Right>\<Right>\<F2>foo", 'xt')
+  call assert_equal('foo line', getline(1))
+
+  " reselect the select mode using gv from a visual mode map
+  vmap <buffer> <F2> gv
+  set selectmode=cmd
+  call feedkeys("0gh\<F2>map", 'xt')
+  call assert_equal('map line', getline(1))
+  set selectmode&
+
+  close!
+endfunc
+
+" Test for changing text in visual mode with 'exclusive' selection
+func Test_exclusive_selection()
+  new
+  call setline(1, ['one', 'two'])
+  set selection=exclusive
+  call feedkeys("vwcabc", 'xt')
+  call assert_equal('abctwo', getline(1))
+  call setline(1, ["\tone"])
+  set virtualedit=all
+  call feedkeys('0v2lcl', 'xt')
+  call assert_equal('l      one', getline(1))
+  set virtualedit&
+  set selection&
+  close!
+endfunc
+
+" Test for starting visual mode with a count
+" This test should be run withou any previous visual modes. So this should be
+" run as a first test.
+func Test_AAA_start_visual_mode_with_count()
+  new
+  call setline(1, ['aaaaaaa', 'aaaaaaa', 'aaaaaaa', 'aaaaaaa'])
+  normal! gg2Vy
+  call assert_equal("aaaaaaa\naaaaaaa\n", @")
+  close!
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab