comparison 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
comparison
equal deleted inserted replaced
19612:a70ee453358e 19613:9c15be376631
657 " linewise select mode: delete middle line 657 " linewise select mode: delete middle line
658 call append('$', ['a', 'b', 'c']) 658 call append('$', ['a', 'b', 'c'])
659 exe "normal GkkgH\<Del>" 659 exe "normal GkkgH\<Del>"
660 call assert_equal(['', 'b', 'c'], getline(1, '$')) 660 call assert_equal(['', 'b', 'c'], getline(1, '$'))
661 661
662
663 " linewise select mode: delete middle two lines 662 " linewise select mode: delete middle two lines
664 call deletebufline('', 1, '$') 663 call deletebufline('', 1, '$')
665 call append('$', ['a', 'b', 'c']) 664 call append('$', ['a', 'b', 'c'])
666 exe "normal GkkgH\<Down>\<Del>" 665 exe "normal GkkgH\<Down>\<Del>"
667 call assert_equal(['', 'c'], getline(1, '$')) 666 call assert_equal(['', 'c'], getline(1, '$'))
677 call append('$', ['a', 'b', 'c']) 676 call append('$', ['a', 'b', 'c'])
678 exe "normal GkgH\<Down>\<Del>" 677 exe "normal GkgH\<Down>\<Del>"
679 call assert_equal(['', 'a'], getline(1, '$')) 678 call assert_equal(['', 'a'], getline(1, '$'))
680 679
681 bwipe! 680 bwipe!
681 endfunc
682
683 " Test for blockwise select mode (g CTRL-H)
684 func Test_blockwise_select_mode()
685 new
686 call setline(1, ['foo', 'bar'])
687 call feedkeys("g\<BS>\<Right>\<Down>mm", 'xt')
688 call assert_equal(['mmo', 'mmr'], getline(1, '$'))
689 close!
682 endfunc 690 endfunc
683 691
684 func Test_visual_mode_put() 692 func Test_visual_mode_put()
685 new 693 new
686 694
906 delmarks < > 914 delmarks < >
907 call assert_fails('*yank', 'E20:') 915 call assert_fails('*yank', 'E20:')
908 close! 916 close!
909 endfunc 917 endfunc
910 918
919 " Test for using visual mode maps in select mode
920 func Test_select_mode_map()
921 new
922 vmap <buffer> <F2> 3l
923 call setline(1, 'Test line')
924 call feedkeys("gh\<F2>map", 'xt')
925 call assert_equal('map line', getline(1))
926
927 vmap <buffer> <F2> ygV
928 call feedkeys("0gh\<Right>\<Right>\<F2>cwabc", 'xt')
929 call assert_equal('abc line', getline(1))
930
931 vmap <buffer> <F2> :<C-U>let v=100<CR>
932 call feedkeys("gggh\<Right>\<Right>\<F2>foo", 'xt')
933 call assert_equal('foo line', getline(1))
934
935 " reselect the select mode using gv from a visual mode map
936 vmap <buffer> <F2> gv
937 set selectmode=cmd
938 call feedkeys("0gh\<F2>map", 'xt')
939 call assert_equal('map line', getline(1))
940 set selectmode&
941
942 close!
943 endfunc
944
945 " Test for changing text in visual mode with 'exclusive' selection
946 func Test_exclusive_selection()
947 new
948 call setline(1, ['one', 'two'])
949 set selection=exclusive
950 call feedkeys("vwcabc", 'xt')
951 call assert_equal('abctwo', getline(1))
952 call setline(1, ["\tone"])
953 set virtualedit=all
954 call feedkeys('0v2lcl', 'xt')
955 call assert_equal('l one', getline(1))
956 set virtualedit&
957 set selection&
958 close!
959 endfunc
960
961 " Test for starting visual mode with a count
962 " This test should be run withou any previous visual modes. So this should be
963 " run as a first test.
964 func Test_AAA_start_visual_mode_with_count()
965 new
966 call setline(1, ['aaaaaaa', 'aaaaaaa', 'aaaaaaa', 'aaaaaaa'])
967 normal! gg2Vy
968 call assert_equal("aaaaaaa\naaaaaaa\n", @")
969 close!
970 endfunc
971
911 " vim: shiftwidth=2 sts=2 expandtab 972 " vim: shiftwidth=2 sts=2 expandtab