]> granicus.if.org Git - vim/commitdiff
patch 7.4.2205 v7.4.2205
authorBram Moolenaar <Bram@vim.org>
Sat, 13 Aug 2016 13:07:41 +0000 (15:07 +0200)
committerBram Moolenaar <Bram@vim.org>
Sat, 13 Aug 2016 13:07:41 +0000 (15:07 +0200)
Problem:    'wildignore' always applies to getcompletion().
Solution:   Add an option to use 'wildignore' or not. (Yegappan Lakshmanan)

runtime/doc/eval.txt
src/evalfunc.c
src/testdir/test_cmdline.vim
src/version.c

index 2ccbab94078c07af711895575e78466b2b18ee8f..6c81575e458c3a8378dbe8718cf8e68ea663a405 100644 (file)
@@ -2093,7 +2093,8 @@ getcmdline()                      String  return the current command-line
 getcmdpos()                    Number  return cursor position in command-line
 getcmdtype()                   String  return current command-line type
 getcmdwintype()                        String  return current command-line window type
-getcompletion({pat}, {type})   List    list of cmdline completion matches
+getcompletion({pat}, {type} [, {filtered}])
+                               List    list of cmdline completion matches
 getcurpos()                    List    position of the cursor
 getcwd([{winnr} [, {tabnr}]])  String  get the current working directory
 getfontname([{name}])          String  name of font being used
@@ -4211,7 +4212,7 @@ getcmdwintype()                                           *getcmdwintype()*
                values are the same as |getcmdtype()|. Returns an empty string
                when not in the command-line window.
 
-getcompletion({pat}, {type})                   *getcompletion()*
+getcompletion({pat}, {type} [, {filtered}])            *getcompletion()*
                Return a list of command-line completion matches. {type}
                specifies what for.  The following completion types are
                supported:
@@ -4251,6 +4252,10 @@ getcompletion({pat}, {type})                     *getcompletion()*
                Otherwise only items matching {pat} are returned. See
                |wildcards| for the use of special characters in {pat}.
 
+               If the optional {filtered} flag is set to 1, then 'wildignore'
+               is applied to filter the results.  Otherwise all the matches
+               are returned. The 'wildignorecase' option always applies.
+
                If there are no matches, an empty list is returned.  An
                invalid value for {type} produces an error.
 
index ab4f9fd15f65f008a9c838df3f0e2f4690525821..379bc634fc84a7a696b77c3da92fe67a5ba2bfe9 100644 (file)
@@ -586,7 +586,7 @@ static struct fst
     {"getcmdtype",     0, 0, f_getcmdtype},
     {"getcmdwintype",  0, 0, f_getcmdwintype},
 #if defined(FEAT_CMDL_COMPL)
-    {"getcompletion",  2, 2, f_getcompletion},
+    {"getcompletion",  2, 3, f_getcompletion},
 #endif
     {"getcurpos",      0, 0, f_getcurpos},
     {"getcwd",         0, 2, f_getcwd},
@@ -4382,12 +4382,20 @@ f_getcompletion(typval_T *argvars, typval_T *rettv)
 {
     char_u     *pat;
     expand_T   xpc;
+    int                filtered = FALSE;
     int                options = WILD_SILENT | WILD_USE_NL | WILD_ADD_SLASH
                                        | WILD_NO_BEEP;
 
+    if (argvars[2].v_type != VAR_UNKNOWN)
+       filtered = get_tv_number_chk(&argvars[2], NULL);
+
     if (p_wic)
        options |= WILD_ICASE;
 
+    /* For filtered results, 'wildignore' is used */
+    if (!filtered)
+       options |= WILD_KEEP_ALL;
+
     ExpandInit(&xpc);
     xpc.xp_pattern = get_tv_string(&argvars[0]);
     xpc.xp_pattern_len = (int)STRLEN(xpc.xp_pattern);
index e2c1876934756db80643c90844d34a6c1f07b3c2..3a35637b7eaddff278eb27eca3fb9bb45632c282 100644 (file)
@@ -94,6 +94,10 @@ func Test_getcompletion()
   call assert_true(index(l, 'runtest.vim') >= 0)
   let l = getcompletion('walk', 'file')
   call assert_equal([], l)
+  set wildignore=*.vim
+  let l = getcompletion('run', 'file', 1)
+  call assert_true(index(l, 'runtest.vim') < 0)
+  set wildignore&
 
   let l = getcompletion('ha', 'filetype')
   call assert_true(index(l, 'hamster') >= 0)
index 11ab8f6f109762f2e1d0a6bd0964612d64312e80..dd7b4b73517e56dd5b3d99691e7d58e6e1eeeffd 100644 (file)
@@ -763,6 +763,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2205,
 /**/
     2204,
 /**/