0
0
mirror of https://github.com/vim/vim.git synced 2025-09-26 04:04:07 -04:00

updated for version 7.4.265

Problem:    Can't call a global function with "g:" in an expression.
Solution:   Skip the "g:" when looking up the function.
This commit is contained in:
Bram Moolenaar
2014-04-24 17:12:33 +02:00
parent eccb7fc315
commit a4f317df89
4 changed files with 19 additions and 9 deletions

View File

@@ -8485,33 +8485,39 @@ call_func(funcname, len, rettv, argcount, argvars, firstline, lastline,
/* execute the function if no errors detected and executing */
if (evaluate && error == ERROR_NONE)
{
char_u *rfname = fname;
/* Ignore "g:" before a function name. */
if (fname[0] == 'g' && fname[1] == ':')
rfname = fname + 2;
rettv->v_type = VAR_NUMBER; /* default rettv is number zero */
rettv->vval.v_number = 0;
error = ERROR_UNKNOWN;
if (!builtin_function(fname, -1))
if (!builtin_function(rfname, -1))
{
/*
* User defined function.
*/
fp = find_func(fname);
fp = find_func(rfname);
#ifdef FEAT_AUTOCMD
/* Trigger FuncUndefined event, may load the function. */
if (fp == NULL
&& apply_autocmds(EVENT_FUNCUNDEFINED,
fname, fname, TRUE, NULL)
rfname, rfname, TRUE, NULL)
&& !aborting())
{
/* executed an autocommand, search for the function again */
fp = find_func(fname);
fp = find_func(rfname);
}
#endif
/* Try loading a package. */
if (fp == NULL && script_autoload(fname, TRUE) && !aborting())
if (fp == NULL && script_autoload(rfname, TRUE) && !aborting())
{
/* loaded a package, search for the function again */
fp = find_func(fname);
fp = find_func(rfname);
}
if (fp != NULL)

View File

@@ -172,11 +172,13 @@ endfun
:endtry
:"
:" function name starting with/without "g:", buffer-local funcref.
:function! g:Foo()
: $put ='called Foo()'
:function! g:Foo(n)
: $put ='called Foo(' . a:n . ')'
:endfunction
:let b:my_func = function('Foo')
:call b:my_func()
:call b:my_func(1)
:echo g:Foo(2)
:echo Foo(3)
:"
:/^start:/+1,$wq! test.out
:" vim: et ts=4 isk-=\: fmr=???,???

Binary file not shown.

View File

@@ -734,6 +734,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
265,
/**/
264,
/**/