Mercurial > vim
diff src/testdir/test_functions.vim @ 33848:c3804ff17204 v9.0.2135
patch 9.0.2135: No test for mode() when executing Ex commands
Commit: https://github.com/vim/vim/commit/fcaeb3d42b228e73c669b2fce78f1d3fe112769f
Author: zeertzjq <zeertzjq@outlook.com>
Date: Tue Nov 28 20:46:29 2023 +0100
patch 9.0.2135: No test for mode() when executing Ex commands
Problem: No test for mode() when executing Ex commands
Solution: Add some test cases and simplify several other test cases.
Also add a few more test cases for ModeChanged.
closes: #13588
Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Tue, 28 Nov 2023 21:00:06 +0100 |
parents | 68de519bab0a |
children | 034445b3af10 |
line wrap: on
line diff
--- a/src/testdir/test_functions.vim +++ b/src/testdir/test_functions.vim @@ -755,7 +755,7 @@ func Test_mode() " Only complete from the current buffer. set complete=. - inoremap <F2> <C-R>=Save_mode()<CR> + noremap! <F2> <C-R>=Save_mode()<CR> xnoremap <F2> <Cmd>call Save_mode()<CR> normal! 3G @@ -914,17 +914,24 @@ func Test_mode() exe "normal g\<C-H>\<C-O>\<F2>\<Esc>" call assert_equal("\<C-V>-\<C-V>s", g:current_modes) - call feedkeys(":echo \<C-R>=Save_mode()\<C-U>\<CR>", 'xt') + call feedkeys(":\<F2>\<CR>", 'xt') call assert_equal('c-c', g:current_modes) - call feedkeys(":\<insert>\<C-r>=Save_mode()\<CR>",'xt') + call feedkeys(":\<Insert>\<F2>\<CR>", 'xt') call assert_equal("c-cr", g:current_modes) - call feedkeys("gQecho \<C-R>=Save_mode()\<CR>\<CR>vi\<CR>", 'xt') + call feedkeys("gQ\<F2>vi\<CR>", 'xt') call assert_equal('c-cv', g:current_modes) - call feedkeys("gQ\<insert>\<C-r>=Save_mode()\<CR>",'xt') + call feedkeys("gQ\<Insert>\<F2>vi\<CR>", 'xt') call assert_equal("c-cvr", g:current_modes) + + " Executing commands in Vim Ex mode should return "cv", never "cvr", + " as Cmdline editing has already ended. + call feedkeys("gQcall Save_mode()\<CR>vi\<CR>", 'xt') + call assert_equal('c-cv', g:current_modes) + call feedkeys("gQ\<Insert>call Save_mode()\<CR>vi\<CR>", 'xt') + call assert_equal('c-cv', g:current_modes) + call feedkeys("Qcall Save_mode()\<CR>vi\<CR>", 'xt') call assert_equal('c-ce', g:current_modes) - " How to test Ex mode? " Test mode in operatorfunc (it used to be Operator-pending). set operatorfunc=OperatorFunc @@ -939,14 +946,15 @@ func Test_mode() call assert_equal('n-niR', g:current_modes) execute "normal! gR\<C-o>g@l\<Esc>" call assert_equal('n-niV', g:current_modes) - " Test statusline updates for overstike mode + + " Test statusline updates for overstrike mode if CanRunVimInTerminal() let buf = RunVimInTerminal('', {'rows': 12}) call term_sendkeys(buf, ":set laststatus=2 statusline=%!mode(1)\<CR>") call term_sendkeys(buf, ":") call TermWait(buf) call VerifyScreenDump(buf, 'Test_mode_1', {}) - call term_sendkeys(buf, "\<insert>") + call term_sendkeys(buf, "\<Insert>") call TermWait(buf) call VerifyScreenDump(buf, 'Test_mode_2', {}) call StopVimInTerminal(buf) @@ -971,7 +979,7 @@ func Test_mode() endif bwipe! - iunmap <F2> + unmap! <F2> xunmap <F2> set complete& set operatorfunc&