changeset 25601:df3d056b4663 v8.2.3337

patch 8.2.3337: completing "call g:" returns entries with just "g:" Commit: https://github.com/vim/vim/commit/069f90852f1444cac50491c10dfbd339a3f9e0c8 Author: Bram Moolenaar <Bram@vim.org> Date: Fri Aug 13 17:48:25 2021 +0200 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 https://github.com/vim/vim/issues/8753)
author Bram Moolenaar <Bram@vim.org>
date Fri, 13 Aug 2021 18:00:04 +0200
parents 096a366a921f
children 39d590a60afb
files src/evalfunc.c src/testdir/test_cmdline.vim src/version.c
diffstat 3 files changed, 8 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -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);
--- a/src/testdir/test_cmdline.vim
+++ b/src/testdir/test_cmdline.vim
@@ -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()
--- a/src/version.c
+++ b/src/version.c
@@ -756,6 +756,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    3337,
+/**/
     3336,
 /**/
     3335,