Skip to content

Commit 5aec755

Browse files
obcatbrammool
authored andcommitted
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 #8765, closes #8774)
1 parent c66f645 commit 5aec755

3 files changed

Lines changed: 14 additions & 3 deletions

File tree

src/evalfunc.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2307,9 +2307,10 @@ get_function_name(expand_T *xp, int idx)
23072307
if (intidx < 0)
23082308
{
23092309
name = get_user_func_name(xp, idx);
2310-
if (name != NULL && *name != NUL)
2310+
if (name != NULL)
23112311
{
2312-
if (*name != '<' && STRNCMP("g:", xp->xp_pattern, 2) == 0)
2312+
if (*name != NUL && *name != '<'
2313+
&& STRNCMP("g:", xp->xp_pattern, 2) == 0)
23132314
return cat_prefix_varname('g', name);
23142315
return name;
23152316
}

src/testdir/test_cmdline.vim

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,7 @@ endfunc
650650

651651
func Test_cmdline_complete_user_func()
652652
call feedkeys(":func Test_cmdline_complete_user\<Tab>\<Home>\"\<cr>", 'tx')
653-
call assert_match('"func Test_cmdline_complete_user', @:)
653+
call assert_match('"func Test_cmdline_complete_user_', @:)
654654
call feedkeys(":func s:ScriptL\<Tab>\<Home>\"\<cr>", 'tx')
655655
call assert_match('"func <SNR>\d\+_ScriptLocalFunction', @:)
656656

@@ -662,6 +662,14 @@ func Test_cmdline_complete_user_func()
662662
let Fx = { a -> a }
663663
call feedkeys(":echo g:\<Tab>\<Home>\"\<cr>", 'tx')
664664
call assert_match('"echo g:[A-Z]', @:)
665+
666+
" existence of script-local dict function does not break user function name
667+
" completion
668+
function s:a_dict_func() dict
669+
endfunction
670+
call feedkeys(":call Test_cmdline_complete_user\<Tab>\<Home>\"\<cr>", 'tx')
671+
call assert_match('"call Test_cmdline_complete_user_', @:)
672+
delfunction s:a_dict_func
665673
endfunc
666674

667675
func Test_cmdline_complete_user_names()

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,8 @@ static char *(features[]) =
755755

756756
static int included_patches[] =
757757
{ /* Add new patch number below this line */
758+
/**/
759+
3360,
758760
/**/
759761
3359,
760762
/**/

0 commit comments

Comments
 (0)