forked from aniani/vim
patch 8.2.2566: Vim9: Function name is not recognized
Problem: Vim9: Function name is not recognized. Solution: Change lookup_scriptvar() to also find function names. (closes #7770)
This commit is contained in:
@@ -2788,11 +2788,11 @@ get_script_local_ht(void)
|
||||
}
|
||||
|
||||
/*
|
||||
* Look for "name[len]" in script-local variables.
|
||||
* Look for "name[len]" in script-local variables and functions.
|
||||
* Return OK when found, FAIL when not found.
|
||||
*/
|
||||
int
|
||||
lookup_scriptvar(
|
||||
lookup_scriptitem(
|
||||
char_u *name,
|
||||
size_t len,
|
||||
cctx_T *dummy UNUSED)
|
||||
@@ -2802,6 +2802,8 @@ lookup_scriptvar(
|
||||
char_u *p;
|
||||
int res;
|
||||
hashitem_T *hi;
|
||||
int is_global = FALSE;
|
||||
char_u *fname = name;
|
||||
|
||||
if (ht == NULL)
|
||||
return FAIL;
|
||||
@@ -2824,9 +2826,24 @@ lookup_scriptvar(
|
||||
// if not script-local, then perhaps imported
|
||||
if (res == FAIL && find_imported(p, 0, NULL) != NULL)
|
||||
res = OK;
|
||||
|
||||
if (p != buffer)
|
||||
vim_free(p);
|
||||
|
||||
if (res != OK)
|
||||
{
|
||||
// Find a function, so that a following "->" works. Skip "g:" before a
|
||||
// function name.
|
||||
// Do not check for an internal function, since it might also be a
|
||||
// valid command, such as ":split" versuse "split()".
|
||||
if (name[0] == 'g' && name[1] == ':')
|
||||
{
|
||||
is_global = TRUE;
|
||||
fname = name + 2;
|
||||
}
|
||||
if (find_func(fname, is_global, NULL) != NULL)
|
||||
res = OK;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user