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:
18
src/eval.c
18
src/eval.c
@@ -8485,33 +8485,39 @@ call_func(funcname, len, rettv, argcount, argvars, firstline, lastline,
|
|||||||
/* execute the function if no errors detected and executing */
|
/* execute the function if no errors detected and executing */
|
||||||
if (evaluate && error == ERROR_NONE)
|
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->v_type = VAR_NUMBER; /* default rettv is number zero */
|
||||||
rettv->vval.v_number = 0;
|
rettv->vval.v_number = 0;
|
||||||
error = ERROR_UNKNOWN;
|
error = ERROR_UNKNOWN;
|
||||||
|
|
||||||
if (!builtin_function(fname, -1))
|
if (!builtin_function(rfname, -1))
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* User defined function.
|
* User defined function.
|
||||||
*/
|
*/
|
||||||
fp = find_func(fname);
|
fp = find_func(rfname);
|
||||||
|
|
||||||
#ifdef FEAT_AUTOCMD
|
#ifdef FEAT_AUTOCMD
|
||||||
/* Trigger FuncUndefined event, may load the function. */
|
/* Trigger FuncUndefined event, may load the function. */
|
||||||
if (fp == NULL
|
if (fp == NULL
|
||||||
&& apply_autocmds(EVENT_FUNCUNDEFINED,
|
&& apply_autocmds(EVENT_FUNCUNDEFINED,
|
||||||
fname, fname, TRUE, NULL)
|
rfname, rfname, TRUE, NULL)
|
||||||
&& !aborting())
|
&& !aborting())
|
||||||
{
|
{
|
||||||
/* executed an autocommand, search for the function again */
|
/* executed an autocommand, search for the function again */
|
||||||
fp = find_func(fname);
|
fp = find_func(rfname);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
/* Try loading a package. */
|
/* 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 */
|
/* loaded a package, search for the function again */
|
||||||
fp = find_func(fname);
|
fp = find_func(rfname);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fp != NULL)
|
if (fp != NULL)
|
||||||
|
@@ -172,11 +172,13 @@ endfun
|
|||||||
:endtry
|
:endtry
|
||||||
:"
|
:"
|
||||||
:" function name starting with/without "g:", buffer-local funcref.
|
:" function name starting with/without "g:", buffer-local funcref.
|
||||||
:function! g:Foo()
|
:function! g:Foo(n)
|
||||||
: $put ='called Foo()'
|
: $put ='called Foo(' . a:n . ')'
|
||||||
:endfunction
|
:endfunction
|
||||||
:let b:my_func = function('Foo')
|
: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
|
:/^start:/+1,$wq! test.out
|
||||||
:" vim: et ts=4 isk-=\: fmr=???,???
|
:" vim: et ts=4 isk-=\: fmr=???,???
|
||||||
|
Binary file not shown.
@@ -734,6 +734,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
265,
|
||||||
/**/
|
/**/
|
||||||
264,
|
264,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user