assert_match('<SNR>\d*_UseMember\_s*' ..
'var d = {func: Legacy}\_s*' ..
'\d PUSHS "func"\_s*' ..
- '\d PUSHFUNC "Legacy"\_s*' ..
+ '\d PUSHFUNC "g:Legacy"\_s*' ..
'\d NEWDICT size 1\_s*' ..
'\d STORE $0\_s*' ..
g:result = getreg('"')->count(' ')
return ''
enddef
+ # global function works at script level
&operatorfunc = g:CountSpaces
new
'a b c d e'->setline(1)
feedkeys("g@_", 'x')
assert_equal(4, g:result)
+
+ &operatorfunc = ''
+ g:result = 0
+ # global function works in :def function
+ def Func()
+ &operatorfunc = g:CountSpaces
+ enddef
+ Func()
+ feedkeys("g@_", 'x')
+ assert_equal(4, g:result)
+
bwipe!
END
CheckScriptSuccess(lines)
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 3826,
/**/
3825,
/**/
generate_PUSHFUNC(cctx_T *cctx, char_u *name, type_T *type)
{
isn_T *isn;
+ char_u *funcname;
RETURN_OK_IF_SKIP(cctx);
if ((isn = generate_instr_type(cctx, ISN_PUSHFUNC, type)) == NULL)
return FAIL;
- isn->isn_arg.string = name == NULL ? NULL : vim_strsave(name);
+ if (name == NULL)
+ funcname = NULL;
+ else if (*name == K_SPECIAL) // script-local
+ funcname = vim_strsave(name);
+ else
+ {
+ funcname = alloc(STRLEN(name) + 3);
+ if (funcname != NULL)
+ {
+ STRCPY(funcname, "g:");
+ STRCPY(funcname + 2, name);
+ }
+ }
+ isn->isn_arg.string = funcname;
return OK;
}