mirror of
https://github.com/vim/vim.git
synced 2025-09-24 03:44:06 -04:00
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.
|
* Return OK when found, FAIL when not found.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
lookup_scriptvar(
|
lookup_scriptitem(
|
||||||
char_u *name,
|
char_u *name,
|
||||||
size_t len,
|
size_t len,
|
||||||
cctx_T *dummy UNUSED)
|
cctx_T *dummy UNUSED)
|
||||||
@@ -2802,6 +2802,8 @@ lookup_scriptvar(
|
|||||||
char_u *p;
|
char_u *p;
|
||||||
int res;
|
int res;
|
||||||
hashitem_T *hi;
|
hashitem_T *hi;
|
||||||
|
int is_global = FALSE;
|
||||||
|
char_u *fname = name;
|
||||||
|
|
||||||
if (ht == NULL)
|
if (ht == NULL)
|
||||||
return FAIL;
|
return FAIL;
|
||||||
@@ -2824,9 +2826,24 @@ lookup_scriptvar(
|
|||||||
// if not script-local, then perhaps imported
|
// if not script-local, then perhaps imported
|
||||||
if (res == FAIL && find_imported(p, 0, NULL) != NULL)
|
if (res == FAIL && find_imported(p, 0, NULL) != NULL)
|
||||||
res = OK;
|
res = OK;
|
||||||
|
|
||||||
if (p != buffer)
|
if (p != buffer)
|
||||||
vim_free(p);
|
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;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1829,7 +1829,7 @@ do_one_cmd(
|
|||||||
if (ea.cmd == cmd + 1 && *cmd == '$')
|
if (ea.cmd == cmd + 1 && *cmd == '$')
|
||||||
// should be "$VAR = val"
|
// should be "$VAR = val"
|
||||||
--ea.cmd;
|
--ea.cmd;
|
||||||
p = find_ex_command(&ea, NULL, lookup_scriptvar, NULL);
|
p = find_ex_command(&ea, NULL, lookup_scriptitem, NULL);
|
||||||
if (ea.cmdidx == CMD_SIZE)
|
if (ea.cmdidx == CMD_SIZE)
|
||||||
{
|
{
|
||||||
char_u *ar = skip_range(ea.cmd, TRUE, NULL);
|
char_u *ar = skip_range(ea.cmd, TRUE, NULL);
|
||||||
|
@@ -61,7 +61,7 @@ void check_vars(char_u *name, int len);
|
|||||||
dictitem_T *find_var(char_u *name, hashtab_T **htp, int no_autoload);
|
dictitem_T *find_var(char_u *name, hashtab_T **htp, int no_autoload);
|
||||||
dictitem_T *find_var_in_ht(hashtab_T *ht, int htname, char_u *varname, int no_autoload);
|
dictitem_T *find_var_in_ht(hashtab_T *ht, int htname, char_u *varname, int no_autoload);
|
||||||
hashtab_T *get_script_local_ht(void);
|
hashtab_T *get_script_local_ht(void);
|
||||||
int lookup_scriptvar(char_u *name, size_t len, cctx_T *dummy);
|
int lookup_scriptitem(char_u *name, size_t len, cctx_T *dummy);
|
||||||
hashtab_T *find_var_ht(char_u *name, char_u **varname);
|
hashtab_T *find_var_ht(char_u *name, char_u **varname);
|
||||||
char_u *get_var_value(char_u *name);
|
char_u *get_var_value(char_u *name);
|
||||||
void new_script_vars(scid_T id);
|
void new_script_vars(scid_T id);
|
||||||
|
@@ -371,6 +371,24 @@ def Test_method_call_linebreak()
|
|||||||
MethodAfterLinebreak('foobar')
|
MethodAfterLinebreak('foobar')
|
||||||
assert_equal('foobar', getline(1))
|
assert_equal('foobar', getline(1))
|
||||||
bwipe!
|
bwipe!
|
||||||
|
|
||||||
|
lines =<< trim END
|
||||||
|
vim9script
|
||||||
|
def Foo(): string
|
||||||
|
return '# some text'
|
||||||
|
enddef
|
||||||
|
|
||||||
|
def Bar(F: func): string
|
||||||
|
return F()
|
||||||
|
enddef
|
||||||
|
|
||||||
|
Foo
|
||||||
|
->Bar()
|
||||||
|
->setline(1)
|
||||||
|
END
|
||||||
|
CheckScriptSuccess(lines)
|
||||||
|
assert_equal('# some text', getline(1))
|
||||||
|
bwipe!
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def Test_method_call_whitespace()
|
def Test_method_call_whitespace()
|
||||||
|
@@ -750,6 +750,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 */
|
||||||
|
/**/
|
||||||
|
2566,
|
||||||
/**/
|
/**/
|
||||||
2565,
|
2565,
|
||||||
/**/
|
/**/
|
||||||
|
@@ -138,7 +138,7 @@ ex_export(exarg_T *eap)
|
|||||||
}
|
}
|
||||||
|
|
||||||
eap->cmd = eap->arg;
|
eap->cmd = eap->arg;
|
||||||
(void)find_ex_command(eap, NULL, lookup_scriptvar, NULL);
|
(void)find_ex_command(eap, NULL, lookup_scriptitem, NULL);
|
||||||
switch (eap->cmdidx)
|
switch (eap->cmdidx)
|
||||||
{
|
{
|
||||||
case CMD_let:
|
case CMD_let:
|
||||||
|
Reference in New Issue
Block a user