changeset 23598:a9433f834693 v8.2.2341

patch 8.2.2341: expresison command line completion incomplete after "g:" Commit: https://github.com/vim/vim/commit/1bb4de5302ba038b9c59e845b6d735e87d5681d0 Author: Bram Moolenaar <Bram@vim.org> Date: Wed Jan 13 19:48:46 2021 +0100 patch 8.2.2341: expresison command line completion incomplete after "g:" Problem: Expresison command line completion shows variables but not functions after "g:". (Gary Johnson) Solution: Prefix "g:" when needed to a global function.
author Bram Moolenaar <Bram@vim.org>
date Wed, 13 Jan 2021 20:00:05 +0100
parents 000119fdb207
children 711b6238c995
files src/evalfunc.c src/evalvars.c src/proto/evalvars.pro src/testdir/test_cmdline.vim src/version.c
diffstat 5 files changed, 12 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -1822,7 +1822,11 @@ get_function_name(expand_T *xp, int idx)
     {
 	name = get_user_func_name(xp, idx);
 	if (name != NULL)
+	{
+	    if (*name != '<' && STRNCMP("g:", xp->xp_pattern, 2) == 0)
+		return cat_prefix_varname('g', name);
 	    return name;
+	}
     }
     if (++intidx < (int)(sizeof(global_functions) / sizeof(funcentry_T)))
     {
--- a/src/evalvars.c
+++ b/src/evalvars.c
@@ -1952,7 +1952,7 @@ static int	varnamebuflen = 0;
 /*
  * Function to concatenate a prefix and a variable name.
  */
-    static char_u *
+    char_u *
 cat_prefix_varname(int prefix, char_u *name)
 {
     int		len;
--- a/src/proto/evalvars.pro
+++ b/src/proto/evalvars.pro
@@ -26,6 +26,7 @@ void ex_unletlock(exarg_T *eap, char_u *
 int do_unlet(char_u *name, int forceit);
 void item_lock(typval_T *tv, int deep, int lock, int check_refcount);
 void del_menutrans_vars(void);
+char_u *cat_prefix_varname(int prefix, char_u *name);
 char_u *get_user_var_name(expand_T *xp, int idx);
 char *get_var_special_name(int nr);
 dict_T *get_globvar_dict(void);
--- a/src/testdir/test_cmdline.vim
+++ b/src/testdir/test_cmdline.vim
@@ -619,6 +619,10 @@ func Test_cmdline_complete_user_func()
   call assert_match('"func Test_cmdline_complete_user', @:)
   call feedkeys(":func s:ScriptL\<Tab>\<Home>\"\<cr>", 'tx')
   call assert_match('"func <SNR>\d\+_ScriptLocalFunction', @:)
+
+  " 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', @:)
 endfunc
 
 func Test_cmdline_complete_user_names()
--- a/src/version.c
+++ b/src/version.c
@@ -751,6 +751,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    2341,
+/**/
     2340,
 /**/
     2339,