0
0
mirror of https://github.com/vim/vim.git synced 2025-09-26 04:04:07 -04:00

patch 8.1.0515: reloading a script gives errors for existing functions

Problem:    Reloading a script gives errors for existing functions.
Solution:   Allow redefining a function once when reloading a script.
This commit is contained in:
Bram Moolenaar
2018-11-10 17:33:29 +01:00
parent 1bbb619483
commit ded5f1bed7
10 changed files with 55 additions and 11 deletions

View File

@@ -2330,14 +2330,19 @@ ex_function(exarg_T *eap)
fp = find_func(name);
if (fp != NULL)
{
if (!eap->forceit)
// Function can be replaced with "function!" and when sourcing the
// same script again, but only once.
if (!eap->forceit
&& (fp->uf_script_ctx.sc_sid != current_sctx.sc_sid
|| fp->uf_script_ctx.sc_seq == current_sctx.sc_seq))
{
emsg_funcname(e_funcexts, name);
goto erret;
}
if (fp->uf_calls > 0)
{
emsg_funcname(N_("E127: Cannot redefine function %s: It is in use"),
emsg_funcname(
N_("E127: Cannot redefine function %s: It is in use"),
name);
goto erret;
}