]> granicus.if.org Git - vim/commitdiff
patch 8.2.4366: not enough tests for command line completion v8.2.4366
authorYegappan Lakshmanan <yegappan@yahoo.com>
Sun, 13 Feb 2022 11:45:09 +0000 (11:45 +0000)
committerBram Moolenaar <Bram@vim.org>
Sun, 13 Feb 2022 11:45:09 +0000 (11:45 +0000)
Problem:    Not enough tests for command line completion.
Solution:   Add a few more tests. (Yegappan Lakshmanan, closes #9760)

src/cmdexpand.c
src/testdir/test_cmdline.vim
src/testdir/test_usercommands.vim
src/version.c

index 8e950ab9b44295451f782b236a5c32048a1becc1..2a65a0691e588eaf3939bc06bbac83062b15607f 100644 (file)
@@ -50,6 +50,9 @@ sort_func_compare(const void *s1, const void *s2)
     return STRCMP(p1, p2);
 }
 
+/*
+ * Escape special characters in the cmdline completion matches.
+ */
     static void
 ExpandEscape(
     expand_T   *xp,
index 6d0dc5bef75e567ab7d1021fd1c1012a08582af9..a38499cca1f80de2a14ad0c2a8a98d4c2bff9cd9 100644 (file)
@@ -409,6 +409,12 @@ func Test_getcompletion()
     call assert_equal(cmds, l)
     let l = getcompletion('list ', 'sign')
     call assert_equal(['Testing'], l)
+    let l = getcompletion('de*', 'sign')
+    call assert_equal(['define'], l)
+    let l = getcompletion('p?', 'sign')
+    call assert_equal(['place'], l)
+    let l = getcompletion('j.', 'sign')
+    call assert_equal(['jump'], l)
   endif
 
   " Command line completion tests
@@ -461,6 +467,18 @@ func Test_getcompletion()
   call delete('Xtags')
   set tags&
 
+  edit a~b
+  enew
+  call assert_equal(['a~b'], getcompletion('a~', 'buffer'))
+  bw a~b
+
+  if has('unix')
+    edit Xtest\
+    enew
+    call assert_equal(['Xtest\'], getcompletion('Xtest\', 'buffer'))
+    bw Xtest\
+  endif
+
   call assert_fails("call getcompletion('\\\\@!\\\\@=', 'buffer')", 'E871:')
   call assert_fails('call getcompletion("", "burp")', 'E475:')
   call assert_fails('call getcompletion("abc", [])', 'E475:')
@@ -1006,6 +1024,25 @@ func Test_cmdline_complete_various()
   call feedkeys(":chist\<Esc>\<Esc>", 'xt')
   call assert_equal('"g/a\xb/clearjumps', @:)
   set wildchar&
+
+  " should be able to complete a file name that starts with a '~'.
+  if has('unix')
+    call writefile([], '~Xtest')
+    call feedkeys(":e \\~X\<Tab>\<C-B>\"\<CR>", 'xt')
+    call assert_equal('"e \~Xtest', @:)
+    call delete('~Xtest')
+  endif
+endfunc
+
+" Test for 'wildignorecase'
+func Test_cmdline_wildignorecase()
+  CheckUnix
+  call writefile([], 'XTEST')
+  set wildignorecase
+  call feedkeys(":e xt\<Tab>\<C-B>\"\<CR>", 'xt')
+  call assert_equal('"e XTEST', @:)
+  set wildignorecase&
+  call delete('XTEST')
 endfunc
 
 func Test_cmdline_write_alternatefile()
@@ -1627,6 +1664,14 @@ func Test_wildmode()
   call assert_equal('AAA    AAAA   AAAAA', g:Sline)
   call assert_equal('"b A', @:)
 
+  " when using longest completion match, matches shorter than the argument
+  " should be ignored (happens with :help)
+  set wildmode=longest,full
+  set wildmenu
+  call feedkeys(":help a*\t\<C-B>\"\<CR>", 'xt')
+  call assert_equal('"help a', @:)
+  set wildmenu&
+
   %argdelete
   delcommand MyCmd
   delfunc T
index 331e55f01ae3944f678ea5717bb9101a4e162258..d6ac9650a553fee960deb5a501ddbc719eaf5c3b 100644 (file)
@@ -384,6 +384,17 @@ func Test_CmdCompletion()
   com! -nargs=? -complete=custom,min DoCmd
   call assert_fails("call feedkeys(':DoCmd \t', 'tx')", 'E118:')
 
+  " custom completion for a pattern with a backslash
+  let g:ArgLead = ''
+  func! CustCompl(A, L, P)
+    let g:ArgLead = a:A
+    return ['one', 'two', 'three']
+  endfunc
+  com! -nargs=? -complete=customlist,CustCompl DoCmd
+  call feedkeys(":DoCmd a\\\t", 'xt')
+  call assert_equal('a\', g:ArgLead)
+  delfunc CustCompl
+
   delcom DoCmd
 endfunc
 
index 840a0d36f81930fcdbc29aadfe35d85dd2bc641a..7212b634dd51d8d0b24bf4fe37a62d79d3ae2f3e 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    4366,
 /**/
     4365,
 /**/