0
0
mirror of https://github.com/vim/vim.git synced 2025-09-24 03:44:06 -04:00

patch 8.2.4748: cannot use an imported function in a mapping

Problem:    Cannot use an imported function in a mapping.
Solution:   Recognize <SID>name.Func.
This commit is contained in:
Bram Moolenaar
2022-04-14 12:58:23 +01:00
parent f420ff2440
commit 8944551534
7 changed files with 105 additions and 19 deletions

View File

@@ -1658,6 +1658,29 @@ exec_command(isn_T *iptr)
return OK;
}
/*
* If script "sid" is not loaded yet then load it now.
* Caller must make sure "sid" is a valid script ID.
* "loaded" is set to TRUE if the script had to be loaded.
* Returns FAIL if loading fails, OK if already loaded or loaded now.
*/
int
may_load_script(int sid, int *loaded)
{
scriptitem_T *si = SCRIPT_ITEM(sid);
if (si->sn_state == SN_STATE_NOT_LOADED)
{
*loaded = TRUE;
if (do_source(si->sn_name, FALSE, DOSO_NONE, NULL) == FAIL)
{
semsg(_(e_cant_open_file_str), si->sn_name);
return FAIL;
}
}
return OK;
}
// used for v_instr of typval of VAR_INSTR
struct instr_S {
ectx_T *instr_ectx;
@@ -2632,18 +2655,11 @@ exec_instructions(ectx_T *ectx)
case ISN_SOURCE:
{
scriptitem_T *si = SCRIPT_ITEM(iptr->isn_arg.number);
if (si->sn_state == SN_STATE_NOT_LOADED)
{
SOURCING_LNUM = iptr->isn_lnum;
if (do_source(si->sn_name, FALSE, DOSO_NONE, NULL)
int notused;
SOURCING_LNUM = iptr->isn_lnum;
if (may_load_script((int)iptr->isn_arg.number, &notused)
== FAIL)
{
semsg(_(e_cant_open_file_str), si->sn_name);
goto on_error;
}
}
goto on_error;
}
break;