From afce081b90c1e2c50c3507758c7558a0dfa1f33e Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 27 Apr 2024 15:18:03 +0200 Subject: Adding upstream version 2:8.2.2434. Signed-off-by: Daniel Baumann --- src/testdir/test_cmdline.vim | 1713 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 1713 insertions(+) create mode 100644 src/testdir/test_cmdline.vim (limited to 'src/testdir/test_cmdline.vim') diff --git a/src/testdir/test_cmdline.vim b/src/testdir/test_cmdline.vim new file mode 100644 index 0000000..7f62dfe --- /dev/null +++ b/src/testdir/test_cmdline.vim @@ -0,0 +1,1713 @@ +" Tests for editing the command line. + +source check.vim +source screendump.vim +source view_util.vim +source shared.vim + +func Test_complete_tab() + call writefile(['testfile'], 'Xtestfile') + call feedkeys(":e Xtest\t\r", "tx") + call assert_equal('testfile', getline(1)) + call delete('Xtestfile') +endfunc + +func Test_complete_list() + " We can't see the output, but at least we check the code runs properly. + call feedkeys(":e test\\r", "tx") + call assert_equal('test', expand('%:t')) + + " If a command doesn't support completion, then CTRL-D should be literally + " used. + call feedkeys(":chistory \\\"\", 'xt') + call assert_equal("\"chistory \", @:) +endfunc + +func Test_complete_wildmenu() + call mkdir('Xdir1/Xdir2', 'p') + call writefile(['testfile1'], 'Xdir1/Xtestfile1') + call writefile(['testfile2'], 'Xdir1/Xtestfile2') + call writefile(['testfile3'], 'Xdir1/Xdir2/Xtestfile3') + call writefile(['testfile3'], 'Xdir1/Xdir2/Xtestfile4') + set wildmenu + + " Pressing completes, and moves to next files when pressing again. + call feedkeys(":e Xdir1/\\\", 'tx') + call assert_equal('testfile1', getline(1)) + call feedkeys(":e Xdir1/\\\\", 'tx') + call assert_equal('testfile2', getline(1)) + + " is like but begin with the last match and then go to + " previous. + call feedkeys(":e Xdir1/Xtest\\", 'tx') + call assert_equal('testfile2', getline(1)) + call feedkeys(":e Xdir1/Xtest\\\", 'tx') + call assert_equal('testfile1', getline(1)) + + " / to move to previous/next file. + call feedkeys(":e Xdir1/\\\", 'tx') + call assert_equal('testfile1', getline(1)) + call feedkeys(":e Xdir1/\\\\", 'tx') + call assert_equal('testfile2', getline(1)) + call feedkeys(":e Xdir1/\\\\\", 'tx') + call assert_equal('testfile1', getline(1)) + + " / to go up/down directories. + call feedkeys(":e Xdir1/\\\", 'tx') + call assert_equal('testfile3', getline(1)) + call feedkeys(":e Xdir1/\\\\\", 'tx') + call assert_equal('testfile1', getline(1)) + + " this fails in some Unix GUIs, not sure why + if !has('unix') || !has('gui_running') + " / mappings to go up/down directories when 'wildcharm' is + " different than 'wildchar'. + set wildcharm= + cnoremap + cnoremap + call feedkeys(":e Xdir1/\\\", 'tx') + call assert_equal('testfile3', getline(1)) + call feedkeys(":e Xdir1/\\\\", 'tx') + call assert_equal('testfile1', getline(1)) + set wildcharm=0 + cunmap + cunmap + endif + + " Test for canceling the wild menu by adding a character + redrawstatus + call feedkeys(":e Xdir1/\x\\"\", 'xt') + call assert_equal('"e Xdir1/Xdir2/x', @:) + + " Completion using a relative path + cd Xdir1/Xdir2 + call feedkeys(":e ../\\\\\\"\", 'tx') + call assert_equal('"e Xtestfile3 Xtestfile4', @:) + cd - + + cnoremap wildmenumode() + call feedkeys(":cd Xdir\\\\"\", 'tx') + call assert_equal('"cd Xdir1/1', @:) + cunmap + + " cleanup + %bwipe + call delete('Xdir1/Xdir2/Xtestfile4') + call delete('Xdir1/Xdir2/Xtestfile3') + call delete('Xdir1/Xtestfile2') + call delete('Xdir1/Xtestfile1') + call delete('Xdir1/Xdir2', 'd') + call delete('Xdir1', 'd') + set nowildmenu +endfunc + +func Test_wildmenu_screendump() + CheckScreendump + + let lines =<< trim [SCRIPT] + set wildmenu hlsearch + [SCRIPT] + call writefile(lines, 'XTest_wildmenu') + + let buf = RunVimInTerminal('-S XTest_wildmenu', {'rows': 8}) + call term_sendkeys(buf, ":vim\") + call VerifyScreenDump(buf, 'Test_wildmenu_1', {}) + + call term_sendkeys(buf, "\") + call VerifyScreenDump(buf, 'Test_wildmenu_2', {}) + + call term_sendkeys(buf, "\") + call VerifyScreenDump(buf, 'Test_wildmenu_3', {}) + + call term_sendkeys(buf, "\") + call VerifyScreenDump(buf, 'Test_wildmenu_4', {}) + call term_sendkeys(buf, "\") + + " clean up + call StopVimInTerminal(buf) + call delete('XTest_wildmenu') +endfunc + +func Test_map_completion() + call feedkeys(":map \\"\", 'xt') + call assert_equal('"map ', getreg(':')) + call feedkeys(":map