vim-patch:8.2.3360: user function completion fails with dict function

Problem:    User function completion fails with dict function.
Solution:   Do not stop sequencing through the list if user functions when
            encountering an empty name. (Naohiro Ono, closes vim/vim#8765,
            closes vim/vim#8774)
5aec755b67
This commit is contained in:
Sean Dewar 2021-08-21 16:19:45 +01:00
parent 26b7faf1f2
commit ebd035f08b
No known key found for this signature in database
GPG Key ID: 08CC2C83AD41B581
2 changed files with 12 additions and 3 deletions

View File

@ -119,8 +119,9 @@ char_u *get_function_name(expand_T *xp, int idx)
intidx = -1; intidx = -1;
if (intidx < 0) { if (intidx < 0) {
name = get_user_func_name(xp, idx); name = get_user_func_name(xp, idx);
if (name != NULL && *name != NUL) { if (name != NULL) {
if (*name != '<' && STRNCMP("g:", xp->xp_pattern, 2) == 0) { if (*name != NUL && *name != '<'
&& STRNCMP("g:", xp->xp_pattern, 2) == 0) {
return cat_prefix_varname('g', name); return cat_prefix_varname('g', name);
} }
return name; return name;

View File

@ -595,7 +595,7 @@ endfunc
func Test_cmdline_complete_user_func() func Test_cmdline_complete_user_func()
call feedkeys(":func Test_cmdline_complete_user\<Tab>\<Home>\"\<cr>", 'tx') call feedkeys(":func Test_cmdline_complete_user\<Tab>\<Home>\"\<cr>", 'tx')
call assert_match('"func Test_cmdline_complete_user', @:) call assert_match('"func Test_cmdline_complete_user_', @:)
call feedkeys(":func s:ScriptL\<Tab>\<Home>\"\<cr>", 'tx') call feedkeys(":func s:ScriptL\<Tab>\<Home>\"\<cr>", 'tx')
call assert_match('"func <SNR>\d\+_ScriptLocalFunction', @:) call assert_match('"func <SNR>\d\+_ScriptLocalFunction', @:)
@ -607,6 +607,14 @@ func Test_cmdline_complete_user_func()
let Fx = { a -> a } let Fx = { a -> a }
call feedkeys(":echo g:\<Tab>\<Home>\"\<cr>", 'tx') call feedkeys(":echo g:\<Tab>\<Home>\"\<cr>", 'tx')
call assert_match('"echo g:[A-Z]', @:) call assert_match('"echo g:[A-Z]', @:)
" existence of script-local dict function does not break user function name
" completion
function s:a_dict_func() dict
endfunction
call feedkeys(":call Test_cmdline_complete_user\<Tab>\<Home>\"\<cr>", 'tx')
call assert_match('"call Test_cmdline_complete_user_', @:)
delfunction s:a_dict_func
endfunc endfunc
func Test_cmdline_complete_user_names() func Test_cmdline_complete_user_names()