mirror of
https://github.com/neovim/neovim.git
synced 2024-12-23 20:55:18 -07:00
parent
595acbbc42
commit
9d200cd0a3
@ -3998,6 +3998,7 @@ getcompletion({pat}, {type} [, {filtered}]) *getcompletion()*
|
||||
augroup autocmd groups
|
||||
buffer buffer names
|
||||
behave :behave suboptions
|
||||
cmdline |cmdline-completion|
|
||||
color color schemes
|
||||
command Ex command (and arguments)
|
||||
compiler compilers
|
||||
@ -4026,7 +4027,7 @@ getcompletion({pat}, {type} [, {filtered}]) *getcompletion()*
|
||||
user user names
|
||||
var user variables
|
||||
|
||||
If {pat} is an empty string, then all the matches are returned.
|
||||
If {pat} is an empty string then all matches are returned.
|
||||
Otherwise only items matching {pat} are returned. See
|
||||
|wildcards| for the use of special characters in {pat}.
|
||||
|
||||
|
@ -10765,16 +10765,23 @@ static void f_getcompletion(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
options |= WILD_KEEP_ALL;
|
||||
}
|
||||
|
||||
if (argvars[0].v_type != VAR_STRING || argvars[1].v_type != VAR_STRING) {
|
||||
EMSG(_(e_invarg));
|
||||
return;
|
||||
}
|
||||
|
||||
if (STRCMP(get_tv_string(&argvars[1]), "cmdline") == 0) {
|
||||
set_one_cmd_context(&xpc, get_tv_string(&argvars[0]));
|
||||
xpc.xp_pattern_len = (int)STRLEN(xpc.xp_pattern);
|
||||
goto theend;
|
||||
}
|
||||
|
||||
ExpandInit(&xpc);
|
||||
xpc.xp_pattern = get_tv_string(&argvars[0]);
|
||||
xpc.xp_pattern_len = (int)STRLEN(xpc.xp_pattern);
|
||||
xpc.xp_context = cmdcomplete_str_to_type(get_tv_string(&argvars[1]));
|
||||
if (xpc.xp_context == EXPAND_NOTHING) {
|
||||
if (argvars[1].v_type == VAR_STRING) {
|
||||
EMSG2(_(e_invarg2), argvars[1].vval.v_string);
|
||||
} else {
|
||||
EMSG(_(e_invarg));
|
||||
}
|
||||
EMSG2(_(e_invarg2), argvars[1].vval.v_string);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -10793,6 +10800,7 @@ static void f_getcompletion(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||
xpc.xp_pattern_len = (int)STRLEN(xpc.xp_pattern);
|
||||
}
|
||||
|
||||
theend:
|
||||
pat = addstar(xpc.xp_pattern, xpc.xp_pattern_len, xpc.xp_context);
|
||||
rettv_list_alloc(rettv);
|
||||
if (pat != NULL) {
|
||||
|
@ -156,6 +156,20 @@ func Test_getcompletion()
|
||||
call assert_equal(['Testing'], l)
|
||||
endif
|
||||
|
||||
" Command line completion tests
|
||||
let l = getcompletion('cd ', 'cmdline')
|
||||
call assert_true(index(l, 'sautest/') >= 0)
|
||||
let l = getcompletion('cd NoMatch', 'cmdline')
|
||||
call assert_equal([], l)
|
||||
let l = getcompletion('let v:n', 'cmdline')
|
||||
call assert_true(index(l, 'v:null') >= 0)
|
||||
let l = getcompletion('let v:notexists', 'cmdline')
|
||||
call assert_equal([], l)
|
||||
let l = getcompletion('call tag', 'cmdline')
|
||||
call assert_true(index(l, 'taglist(') >= 0)
|
||||
let l = getcompletion('call paint', 'cmdline')
|
||||
call assert_equal([], l)
|
||||
|
||||
" For others test if the name is recognized.
|
||||
let names = ['buffer', 'environment', 'file_in_path',
|
||||
\ 'mapping', 'shellcmd', 'tag', 'tag_listfiles', 'user']
|
||||
|
Loading…
Reference in New Issue
Block a user