diff options
author | Bram Moolenaar <Bram@vim.org> | 2020-08-12 15:21:22 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2020-08-12 15:21:22 +0200 |
commit | a177344dc0c337e5b272c1c59d13964a8318bcfa (patch) | |
tree | f7e343d4db0e54ea97e6a3c82fe921db35f6395d /src/vim9execute.c | |
parent | 575f24b3f3d8cd8bfc2da402c2938c0c7ace7877 (diff) | |
download | vim-git-a177344dc0c337e5b272c1c59d13964a8318bcfa.tar.gz |
patch 8.2.1426: Vim9: cannot call autoload function in :def functionv8.2.1426
Problem: Vim9: cannot call autoload function in :def function.
Solution: Load the autoload script. (closes #6690)
Diffstat (limited to 'src/vim9execute.c')
-rw-r--r-- | src/vim9execute.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/vim9execute.c b/src/vim9execute.c index 6e9b53d68..fed7fed0e 100644 --- a/src/vim9execute.c +++ b/src/vim9execute.c @@ -546,6 +546,15 @@ call_ufunc(ufunc_T *ufunc, int argcount, ectx_T *ectx, isn_T *iptr) } /* + * Return TRUE if an error was given or CTRL-C was pressed. + */ + static int +vim9_aborting(int prev_called_emsg) +{ + return called_emsg > prev_called_emsg || got_int || did_throw; +} + +/* * Execute a function by "name". * This can be a builtin function or a user function. * "iptr" can be used to replace the instruction with a more efficient one. @@ -568,6 +577,18 @@ call_by_name(char_u *name, int argcount, ectx_T *ectx, isn_T *iptr) } ufunc = find_func(name, FALSE, NULL); + + if (ufunc == NULL) + { + int called_emsg_before = called_emsg; + + if (script_autoload(name, TRUE)) + // loaded a package, search for the function again + ufunc = find_func(name, FALSE, NULL); + if (vim9_aborting(called_emsg_before)) + return FAIL; // bail out if loading the script caused an error + } + if (ufunc != NULL) return call_ufunc(ufunc, argcount, ectx, iptr); |