]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 8.2.2341: expresison command line completion incomplete after "g:" v8.2.2341
authorBram Moolenaar <Bram@vim.org>
Wed, 13 Jan 2021 18:48:46 +0000 (19:48 +0100)
committerBram Moolenaar <Bram@vim.org>
Wed, 13 Jan 2021 18:48:46 +0000 (19:48 +0100)
Problem:    Expresison command line completion shows variables but not
            functions after "g:". (Gary Johnson)
Solution:   Prefix "g:" when needed to a global function.

src/evalfunc.c
src/evalvars.c
src/proto/evalvars.pro
src/testdir/test_cmdline.vim
src/version.c

index 0e6d759c66460275b9ac2d36bed4504938aa76f4..d3ef15e0b9dd2647f716d0ae6f4f7fda5199fc8a 100644 (file)
@@ -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)))
     {
index 644190fbe16badca42b593620527ab3c0410697d..155f603b5077ff66441338ed5304495c67eff818 100644 (file)
@@ -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;
index c597ca37200fc780c435177da7126068baa4c99d..0861a8866ad95b60a4b2160a56c088373cf2a21a 100644 (file)
@@ -26,6 +26,7 @@ void ex_unletlock(exarg_T *eap, char_u *argstart, int deep, int glv_flags, int (
 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);
index 2a6db7de4fbf493c13be50d2253e462654125265..cb16de12469c903b698437c7dc3fb0fbb6e3ff8e 100644 (file)
@@ -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()
index 24462a0e678af5ca9e94a7b5d49a140356c6562c..78b805f02426923af03fef0b0213cc1cbcacffed 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2341,
 /**/
     2340,
 /**/