From c467df997eadc077003ff27908c0782b27ff6b97 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 13 Jul 2022 21:14:08 +0800 Subject: vim-patch:8.2.0342: some code in ex_getln.c not covered by tests Problem: Some code in ex_getln.c not covered by tests. Solution: Add more tests. (Yegappan Lakshmanan, closes vim/vim#5717) https://github.com/vim/vim/commit/0546d7df13b041833121b2d56036e1c62ea3b0c1 Nvim doesn't support imsearch=2, commenting out that line is enough. Test_Ex_append() is not applicable to Vim enhanced Ex mode. Omit test_iminsert.vim as previous patches to that file are N/A. --- src/nvim/testdir/test_cmdline.vim | 35 +++++++++++++++++++++++++++++++++++ src/nvim/testdir/test_ex_mode.vim | 10 ++++++++++ src/nvim/testdir/test_history.vim | 11 ++++++++++- 3 files changed, 55 insertions(+), 1 deletion(-) diff --git a/src/nvim/testdir/test_cmdline.vim b/src/nvim/testdir/test_cmdline.vim index 3863d25ee7..b5ee5e802d 100644 --- a/src/nvim/testdir/test_cmdline.vim +++ b/src/nvim/testdir/test_cmdline.vim @@ -1558,6 +1558,7 @@ endfunc func Test_cmdline_edit() let str = ":one two\" let str ..= "one two\\" + let str ..= "one\\\" let str ..= "\five\" let str ..= "\two " let str ..= "\one " @@ -1576,6 +1577,7 @@ func Test_cmdline_edit_rightleft() set rightleftcmd=search let str = "/one two\" let str ..= "one two\\" + let str ..= "one\\\" let str ..= "\five\" let str ..= "\two " let str ..= "\one " @@ -1603,6 +1605,39 @@ func Test_cmdline_expr() call assert_equal("\"e \\", @:) endfunc +" Test for 'imcmdline' and 'imsearch' +" This test doesn't actually test the input method functionality. +func Test_cmdline_inputmethod() + new + call setline(1, ['', 'abc', '']) + set imcmdline + + call feedkeys(":\"abc\", 'xt') + call assert_equal("\"abc", @:) + call feedkeys(":\"\abc\\", 'xt') + call assert_equal("\"abc", @:) + call feedkeys("/abc\", 'xt') + call assert_equal([2, 1], [line('.'), col('.')]) + call feedkeys("/\abc\\", 'xt') + call assert_equal([2, 1], [line('.'), col('.')]) + + " set imsearch=2 + call cursor(1, 1) + call feedkeys("/abc\", 'xt') + call assert_equal([2, 1], [line('.'), col('.')]) + call cursor(1, 1) + call feedkeys("/\abc\\", 'xt') + call assert_equal([2, 1], [line('.'), col('.')]) + set imdisable + call feedkeys("/\abc\\", 'xt') + call assert_equal([2, 1], [line('.'), col('.')]) + set imdisable& + set imsearch& + + set imcmdline& + %bwipe! +endfunc + " Test for normal mode commands not supported in the cmd window func Test_cmdwin_blocked_commands() call assert_fails('call feedkeys("q:\\", "xt")', 'E11:') diff --git a/src/nvim/testdir/test_ex_mode.vim b/src/nvim/testdir/test_ex_mode.vim index 2b8c5bebea..8a8203b40b 100644 --- a/src/nvim/testdir/test_ex_mode.vim +++ b/src/nvim/testdir/test_ex_mode.vim @@ -141,6 +141,16 @@ func Test_Ex_escape_enter() call assert_equal("a\rb", l) endfunc +" Test for :append! command in Ex mode +func Test_Ex_append() + throw 'Skipped: Nvim only supports Vim Ex mode' + new + call setline(1, "\t abc") + call feedkeys("Qappend!\npqr\nxyz\n.\nvisual\n", 'xt') + call assert_equal(["\t abc", "\t pqr", "\t xyz"], getline(1, '$')) + close! +endfunc + func Test_ex_mode_errors() " Not allowed to enter ex mode when text is locked au InsertCharPre normal! gQ diff --git a/src/nvim/testdir/test_history.vim b/src/nvim/testdir/test_history.vim index 96006ac7e7..0312b5f579 100644 --- a/src/nvim/testdir/test_history.vim +++ b/src/nvim/testdir/test_history.vim @@ -114,6 +114,7 @@ function Test_Search_history_window() bwipe! endfunc +" Test for :history command option completion function Test_history_completion() call feedkeys(":history \\\"\", 'tx') call assert_equal('"history / : = > ? @ all cmd debug expr input search', @:) @@ -122,8 +123,9 @@ endfunc " Test for increasing the 'history' option value func Test_history_size() let save_histsz = &history - call histdel(':') set history=10 + call histadd(':', 'ls') + call histdel(':') for i in range(1, 5) call histadd(':', 'cmd' .. i) endfor @@ -173,6 +175,13 @@ func Test_history_search() call assert_equal(['pat2', 'pat1', ''], g:pat) cunmap delfunc SavePat + + " Recall patterns with 'history' set to 0 + set history=0 + let @/ = 'abc' + let cmd = 'call feedkeys("/\\\\\", "xt")' + call assert_fails(cmd, 'E486:') + set history& endfunc " Test for making sure the key value is not stored in history -- cgit