Patch 8.2.0396
Problem: Cmdexpand.c insufficiently tested.
Solution: Add more tests. (Yegappan Lakshmanan, closes #5789)
Files: src/testdir/test_cmdline.vim, src/testdir/test_taglist.vim,
src/testdir/test_terminal.vim, src/testdir/test_usercommands.vim
*** ../vim-8.2.0395/src/testdir/test_cmdline.vim 2020-03-10 07:48:06.571619551 +0100
--- src/testdir/test_cmdline.vim 2020-03-16 21:22:45.571133303 +0100
***************
*** 2,7 ****
--- 2,8 ----
source check.vim
source screendump.vim
+ source view_util.vim
func Test_complete_tab()
call writefile(['testfile'], 'Xtestfile')
***************
*** 401,406 ****
--- 402,408 ----
set tags&
call assert_fails('call getcompletion("", "burp")', 'E475:')
+ call assert_fails('call getcompletion("abc", [])', 'E474:')
endfunc
func Test_shellcmd_completion()
***************
*** 641,646 ****
--- 643,791 ----
unlet $X_VIM_TEST_COMPLETE_ENV
endfunc
+ " Test for various command-line completion
+ func Test_cmdline_complete_various()
+ " completion for a command starting with a comment
+ call feedkeys(": :|\"\<C-A>\<C-B>\"\<CR>", 'xt')
+ call assert_equal("\" :|\"\<C-A>", @:)
+
+ " completion for a range followed by a comment
+ call feedkeys(":1,2\"\<C-A>\<C-B>\"\<CR>", 'xt')
+ call assert_equal("\"1,2\"\<C-A>", @:)
+
+ " completion for :k command
+ call feedkeys(":ka\<C-A>\<C-B>\"\<CR>", 'xt')
+ call assert_equal("\"ka\<C-A>", @:)
+
+ " completion for short version of the :s command
+ call feedkeys(":sI \<C-A>\<C-B>\"\<CR>", 'xt')
+ call assert_equal("\"sI \<C-A>", @:)
+
+ " completion for :write command
+ call mkdir('Xdir')
+ call writefile(['one'], 'Xdir/Xfile1')
+ let save_cwd = getcwd()
+ cd Xdir
+ call feedkeys(":w >> \<C-A>\<C-B>\"\<CR>", 'xt')
+ call assert_equal("\"w >> Xfile1", @:)
+ call chdir(save_cwd)
+ call delete('Xdir', 'rf')
+
+ " completion for :w ! and :r ! commands
+ call feedkeys(":w !invalid_xyz_cmd\<C-A>\<C-B>\"\<CR>", 'xt')
+ call assert_equal("\"w !invalid_xyz_cmd", @:)
+ call feedkeys(":r !invalid_xyz_cmd\<C-A>\<C-B>\"\<CR>", 'xt')
+ call assert_equal("\"r !invalid_xyz_cmd", @:)
+
+ " completion for :>> and :<< commands
+ call feedkeys(":>>>\<C-A>\<C-B>\"\<CR>", 'xt')
+ call assert_equal("\">>>\<C-A>", @:)
+ call feedkeys(":<<<\<C-A>\<C-B>\"\<CR>", 'xt')
+ call assert_equal("\"<<<\<C-A>", @:)
+
+ " completion for command with +cmd argument
+ call feedkeys(":buffer +/pat Xabc\<C-A>\<C-B>\"\<CR>", 'xt')
+ call assert_equal("\"buffer +/pat Xabc", @:)
+ call feedkeys(":buffer +/pat\<C-A>\<C-B>\"\<CR>", 'xt')
+ call assert_equal("\"buffer +/pat\<C-A>", @:)
+
+ " completion for a command with a trailing comment
+ call feedkeys(":ls \" comment\<C-A>\<C-B>\"\<CR>", 'xt')
+ call assert_equal("\"ls \" comment\<C-A>", @:)
+
+ " completion for a command with a trailing command
+ call feedkeys(":ls | ls\<C-A>\<C-B>\"\<CR>", 'xt')
+ call assert_equal("\"ls | ls", @:)
+
+ " completion for a command with an CTRL-V escaped argument
+ call feedkeys(":ls \<C-V>\<C-V>a\<C-A>\<C-B>\"\<CR>", 'xt')
+ call assert_equal("\"ls \<C-V>a\<C-A>", @:)
+
+ " completion for a command that doesn't take additional arguments
+ call feedkeys(":all abc\<C-A>\<C-B>\"\<CR>", 'xt')
+ call assert_equal("\"all abc\<C-A>", @:)
+
+ " completion for a command with a command modifier
+ call feedkeys(":topleft new\<C-A>\<C-B>\"\<CR>", 'xt')
+ call assert_equal("\"topleft new", @:)
+
+ " completion for the :match command
+ call feedkeys(":match Search /pat/\<C-A>\<C-B>\"\<CR>", 'xt')
+ call assert_equal("\"match Search /pat/\<C-A>", @:)
+
+ " completion for the :s command
+ call feedkeys(":s/from/to/g\<C-A>\<C-B>\"\<CR>", 'xt')
+ call assert_equal("\"s/from/to/g\<C-A>", @:)
+
+ " completion for the :dlist command
+ call feedkeys(":dlist 10 /pat/ a\<C-A>\<C-B>\"\<CR>", 'xt')
+ call assert_equal("\"dlist 10 /pat/ a\<C-A>", @:)
+
+ " completion for the :doautocmd command
+ call feedkeys(":doautocmd User MyCmd a.c\<C-A>\<C-B>\"\<CR>", 'xt')
+ call assert_equal("\"doautocmd User MyCmd a.c\<C-A>", @:)
+
+ " completion for the :augroup command
+ augroup XTest
+ augroup END
+ call feedkeys(":augroup X\<C-A>\<C-B>\"\<CR>", 'xt')
+ call assert_equal("\"augroup XTest", @:)
+ augroup! XTest
+
+ " completion for the :unlet command
+ call feedkeys(":unlet one two\<C-A>\<C-B>\"\<CR>", 'xt')
+ call assert_equal("\"unlet one two", @:)
+
+ " completion for the :bdelete command
+ call feedkeys(":bdel a b c\<C-A>\<C-B>\"\<CR>", 'xt')
+ call assert_equal("\"bdel a b c", @:)
+
+ " completion for the :mapclear command
+ call feedkeys(":mapclear \<C-A>\<C-B>\"\<CR>", 'xt')
+ call assert_equal("\"mapclear <buffer>", @:)
+
+ " completion for user defined commands with menu names
+ menu Test.foo :ls<CR>
+ com -nargs=* -complete=menu MyCmd
+ call feedkeys(":MyCmd Te\<C-A>\<C-B>\"\<CR>", 'xt')
+ call assert_equal('"MyCmd Test.', @:)
+ delcom MyCmd
+ unmenu Test
+
+ " completion for user defined commands with mappings
+ mapclear
+ map <F3> :ls<CR>
+ com -nargs=* -complete=mapping MyCmd
+ call feedkeys(":MyCmd <F\<C-A>\<C-B>\"\<CR>", 'xt')
+ call assert_equal('"MyCmd <F3>', @:)
+ mapclear
+ delcom MyCmd
+
+ " completion for :set path= with multiple backslashes
+ call feedkeys(":set path=a\\\\\\ b\<C-A>\<C-B>\"\<CR>", 'xt')
+ call assert_equal('"set path=a\\\ b', @:)
+
+ " completion for :set dir= with a backslash
+ call feedkeys(":set dir=a\\ b\<C-A>\<C-B>\"\<CR>", 'xt')
+ call assert_equal('"set dir=a\ b', @:)
+
+ " completion for the :py3 commands
+ call feedkeys(":py3\<C-A>\<C-B>\"\<CR>", 'xt')
+ call assert_equal('"py3 py3do py3file', @:)
+
+ " redir @" is not the start of a comment. So complete after that
+ call feedkeys(":redir @\" | cwin\t\<C-B>\"\<CR>", 'xt')
+ call assert_equal('"redir @" | cwindow', @:)
+
+ " completion after a backtick
+ call feedkeys(":e `a1b2c\t\<C-B>\"\<CR>", 'xt')
+ call assert_equal('"e `a1b2c', @:)
+
+ " completion for the expression register
+ call feedkeys(":\"\<C-R>=float2\t\"\<C-B>\"\<CR>", 'xt')
+ call assert_equal('"float2nr("', @=)
+ endfunc
+
func Test_cmdline_write_alternatefile()
new
call setline('.', ['one', 'two'])
***************
*** 1116,1130 ****
close!
endfunc
- " Return the 'len' characters in screen starting from (row,col)
- func s:ScreenLine(row, col, len)
- let s = ''
- for i in range(a:len)
- let s .= nr2char(screenchar(a:row, a:col + i))
- endfor
- return s
- endfunc
-
" Test for 'wildmode'
func Test_wildmode()
func T(a, c, p)
--- 1261,1266 ----
***************
*** 1133,1139 ****
command -nargs=1 -complete=custom,T MyCmd
func SaveScreenLine()
! let g:Sline = s:ScreenLine(&lines - 1, 1, 20)
return ''
endfunc
cnoremap <expr> <F2> SaveScreenLine()
--- 1269,1275 ----
command -nargs=1 -complete=custom,T MyCmd
func SaveScreenLine()
! let g:Sline = Screenline(&lines - 1)
return ''
endfunc
cnoremap <expr> <F2> SaveScreenLine()
***************
*** 1142,1148 ****
set wildmode=full,list
let g:Sline = ''
call feedkeys(":MyCmd \t\t\<F2>\<C-B>\"\<CR>", 'xt')
! call assert_equal('oneA oneB oneC ', g:Sline)
call assert_equal('"MyCmd oneA', @:)
set wildmode=longest,full
--- 1278,1284 ----
set wildmode=full,list
let g:Sline = ''
call feedkeys(":MyCmd \t\t\<F2>\<C-B>\"\<CR>", 'xt')
! call assert_equal('oneA oneB oneC', g:Sline)
call assert_equal('"MyCmd oneA', @:)
set wildmode=longest,full
***************
*** 1158,1175 ****
set wildmode=list:longest
let g:Sline = ''
call feedkeys(":MyCmd \t\<F2>\<C-B>\"\<CR>", 'xt')
! call assert_equal('oneA oneB oneC ', g:Sline)
call assert_equal('"MyCmd one', @:)
set wildmode=""
call feedkeys(":MyCmd \t\t\<C-B>\"\<CR>", 'xt')
call assert_equal('"MyCmd oneA', @:)
delcommand MyCmd
delfunc T
delfunc SaveScreenLine
cunmap <F2>
set wildmode&
endfunc
" Test for interrupting the command-line completion
--- 1294,1328 ----
set wildmode=list:longest
let g:Sline = ''
call feedkeys(":MyCmd \t\<F2>\<C-B>\"\<CR>", 'xt')
! call assert_equal('oneA oneB oneC', g:Sline)
call assert_equal('"MyCmd one', @:)
set wildmode=""
call feedkeys(":MyCmd \t\t\<C-B>\"\<CR>", 'xt')
call assert_equal('"MyCmd oneA', @:)
+ " Test for wildmode=longest with 'fileignorecase' set
+ set wildmode=longest
+ set fileignorecase
+ argadd AA AAA AAAA
+ call feedkeys(":buffer \t\<C-B>\"\<CR>", 'xt')
+ call assert_equal('"buffer AA', @:)
+ set fileignorecase&
+
+ " Test for listing files with wildmode=list
+ set wildmode=list
+ let g:Sline = ''
+ call feedkeys(":b A\t\t\<F2>\<C-B>\"\<CR>", 'xt')
+ call assert_equal('AA AAA AAAA', g:Sline)
+ call assert_equal('"b A', @:)
+
+ %argdelete
delcommand MyCmd
delfunc T
delfunc SaveScreenLine
cunmap <F2>
set wildmode&
+ %bwipe!
endfunc
" Test for interrupting the command-line completion
*** ../vim-8.2.0395/src/testdir/test_taglist.vim 2020-03-09 08:17:47.934476791 +0100
--- src/testdir/test_taglist.vim 2020-03-16 21:22:45.571133303 +0100
***************
*** 1,5 ****
--- 1,7 ----
" test taglist(), tagfiles() functions and :tags command
+ source view_util.vim
+
func Test_taglist()
call writefile([
\ "FFoo\tXfoo\t1",
***************
*** 216,218 ****
--- 218,238 ----
set tags&
call delete('Xtags')
endfunc
+
+ " Test for :tag command completion with 'wildoptions' set to 'tagfile'
+ func Test_tag_complete_wildoptions()
+ call writefile(["foo\ta.c\t10;\"\tf", "bar\tb.c\t20;\"\td"], 'Xtags')
+ set tags=Xtags
+ set wildoptions=tagfile
+
+ call feedkeys(":tag \<C-D>\<C-R>=Screenline(&lines - 1)\<CR> : "
+ \ .. "\<C-R>=Screenline(&lines - 2)\<CR>\<C-B>\"\<CR>", 'xt')
+
+ call assert_equal('"tag bar d b.c : foo f a.c', @:)
+
+ call delete('Xtags')
+ set wildoptions&
+ set tags&
+ endfunc
+
+ " vim: shiftwidth=2 sts=2 expandtab
*** ../vim-8.2.0395/src/testdir/test_terminal.vim 2020-03-15 20:33:11.288799820 +0100
--- src/testdir/test_terminal.vim 2020-03-16 21:22:45.571133303 +0100
***************
*** 2495,2501 ****
call term_sendkeys(g:buf0, "exit\<CR>")
sleep 100m
! exe g:buf0 .. 'bwipe'
set hidden&
endfunc
--- 2495,2501 ----
call term_sendkeys(g:buf0, "exit\<CR>")
sleep 100m
! exe g:buf0 .. 'bwipe!'
set hidden&
endfunc
*** ../vim-8.2.0395/src/testdir/test_usercommands.vim 2019-05-01 17:16:53.000000000 +0200
--- src/testdir/test_usercommands.vim 2020-03-16 21:22:45.571133303 +0100
***************
*** 262,268 ****
endfunc
func CustomCompleteList(A, L, P)
! return [ "Monday", "Tuesday", "Wednesday" ]
endfunc
func Test_CmdCompletion()
--- 262,268 ----
endfunc
func CustomCompleteList(A, L, P)
! return [ "Monday", "Tuesday", "Wednesday", {}]
endfunc
func Test_CmdCompletion()
***************
*** 327,332 ****
--- 327,338 ----
com! -complete=customlist,CustomComp DoCmd :
call assert_fails("call feedkeys(':DoCmd \<C-D>', 'tx')", 'E117:')
+
+ " custom completion without a function
+ com! -complete=custom, DoCmd
+ call assert_beeps("call feedkeys(':DoCmd \t', 'tx')")
+
+ delcom DoCmd
endfunc
func CallExecute(A, L, P)
***************
*** 542,544 ****
--- 548,552 ----
call assert_equal("\nNo user-defined commands found", execute(':command Xxx'))
call assert_equal("\nNo user-defined commands found", execute('command'))
endfunc
+
+ " vim: shiftwidth=2 sts=2 expandtab
*** ../vim-8.2.0395/src/version.c 2020-03-16 21:08:28.581879755 +0100
--- src/version.c 2020-03-16 21:24:13.318834114 +0100
***************
*** 740,741 ****
--- 740,743 ----
{ /* Add new patch number below this line */
+ /**/
+ 396,
/**/
--
A KNIGHT rides into shot and hacks him to the ground. He rides off.
We stay for a moment on the glade. A MIDDLE-AGED LADY in a C. & A.
twin-set emerges from the trees and looks in horror at the body of her
HUSBAND.
MRS HISTORIAN: FRANK!
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
/// Bram Moolenaar -- Br...@Moolenaar.net --
http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features --
http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language --
http://www.Zimbu.org ///
\\\ help me help AIDS victims --
http://ICCF-Holland.org ///