]> granicus.if.org Git - vim/commitdiff
patch 8.2.3337: completing "call g:" returns entries with just "g:" v8.2.3337
authorBram Moolenaar <Bram@vim.org>
Fri, 13 Aug 2021 15:48:25 +0000 (17:48 +0200)
committerBram Moolenaar <Bram@vim.org>
Fri, 13 Aug 2021 15:48:25 +0000 (17:48 +0200)
Problem:    Completing "call g:" returns entries with just "g:". (Naohiro Ono)
Solution:   Skip empty strings returned by get_user_func_name(). (closes #8753)

src/evalfunc.c
src/testdir/test_cmdline.vim
src/version.c

index b90c6d760d83e2afa73dc8f4c4c7d79bdbd4acae..2b50798f4fe930f8b367877d0ebc10a7c01c2e83 100644 (file)
@@ -2304,7 +2304,7 @@ get_function_name(expand_T *xp, int idx)
     if (intidx < 0)
     {
        name = get_user_func_name(xp, idx);
-       if (name != NULL)
+       if (name != NULL && *name != NUL)
        {
            if (*name != '<' && STRNCMP("g:", xp->xp_pattern, 2) == 0)
                return cat_prefix_varname('g', name);
index 90afe4516c0fde56ee919b1eac42fc118629c5db..3c5513b88e87911dc53c9b1ab8ad5d459017597c 100644 (file)
@@ -657,6 +657,11 @@ func Test_cmdline_complete_user_func()
   " g: prefix also works
   call feedkeys(":echo g:Test_cmdline_complete_user_f\<Tab>\<Home>\"\<cr>", 'tx')
   call assert_match('"echo g:Test_cmdline_complete_user_func', @:)
+
+  " using g: prefix does not result in just "g:" matches from a lambda
+  let Fx = { a ->  a }
+  call feedkeys(":echo g:\<Tab>\<Home>\"\<cr>", 'tx')
+  call assert_match('"echo g:[A-Z]', @:)
 endfunc
 
 func Test_cmdline_complete_user_names()
index a31b4941a58532948ba623a39e8939752e47430d..64137dbd0014d955d179b55d52eb153514cbd0f4 100644 (file)
@@ -755,6 +755,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    3337,
 /**/
     3336,
 /**/