patch 8.2.3337: completing "call g:" returns entries with just "g:"
Problem: Completing "call g:" returns entries with just "g:". (Naohiro Ono)
Solution: Skip empty strings returned by get_user_func_name(). (closes #8753)
diff --git a/src/evalfunc.c b/src/evalfunc.c
index b90c6d7..2b50798 100644
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -2304,7 +2304,7 @@
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);
diff --git a/src/testdir/test_cmdline.vim b/src/testdir/test_cmdline.vim
index 90afe45..3c5513b 100644
--- a/src/testdir/test_cmdline.vim
+++ b/src/testdir/test_cmdline.vim
@@ -657,6 +657,11 @@
" 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()
diff --git a/src/version.c b/src/version.c
index a31b494..64137db 100644
--- a/src/version.c
+++ b/src/version.c
@@ -756,6 +756,8 @@
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 3337,
+/**/
3336,
/**/
3335,