Hi Bram,
On Tue, Aug 9, 2016 at 12:52 PM, Bram Moolenaar <[email protected]> wrote:
>
> Yegappan wrote:
>
>> The getcompletion() function applies the 'wildignore' option setting
>> and removes all the entries matching the file patterns in
>> 'wildignore'. Currently, there is no way to disable this. Do you think
>> we should add a 'flag' argument to getcompletion() to ignore/support
>> 'wildignore'?
>
> Yes, that makes sense. Perhaps a generic flag whether to return what
> would happen on the command line, or the "full result" without
> filtering. We should also document that 'wildignore' is used for
> getcompletion(), it only mentions expand() and glob().
>
I am attaching a patch to add an optional argument to the
getcompletion() function. When the optional argument is set
to TRUE, then the 'wildignore' and 'wildignore' settings are
applied. Otherwise the unfiltered results are returned.
- Yegappan
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt
index 39765d5..dc88473 100644
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -2092,7 +2092,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} [, {cmdline}])
+ 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
@@ -4158,7 +4159,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} [, {cmdline}]) *getcompletion()*
Return a list of command-line completion matches. {type}
specifies what for. The following completion types are
supported:
@@ -4198,6 +4199,11 @@ getcompletion({pat}, {type})
*getcompletion()*
Otherwise only items matching {pat} are returned. See
|wildcards| for the use of special characters in {pat}.
+ If the optional {cmdline} flag is supplied, then 'wildignore'
+ and 'wildignorecase' are applied to filter the results.
+ Otherwise, these options are ignored and all the matches are
+ returned.
+
If there are no matches, an empty list is returned. An
invalid value for {type} produces an error.
diff --git a/src/evalfunc.c b/src/evalfunc.c
index 8b5ad22..1c2e364 100644
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -581,7 +581,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},
@@ -4220,12 +4220,23 @@ f_getcompletion(typval_T *argvars, typval_T *rettv)
{
char_u *pat;
expand_T xpc;
+ int cmdline_flag = FALSE;
int options = WILD_SILENT | WILD_USE_NL | WILD_ADD_SLASH
| WILD_NO_BEEP;
- if (p_wic)
+ if (argvars[2].v_type != VAR_UNKNOWN)
+ cmdline_flag = get_tv_number_chk(&argvars[2], NULL);
+
+ /*
+ * For command line completion like results, 'wildignorecase' and
+ * 'wildignore' applies
+ */
+ if (cmdline_flag && p_wic)
options |= WILD_ICASE;
+ if (!cmdline_flag)
+ options |= WILD_KEEP_ALL;
+
ExpandInit(&xpc);
xpc.xp_pattern = get_tv_string(&argvars[0]);
xpc.xp_pattern_len = (int)STRLEN(xpc.xp_pattern);