From: Bram Moolenaar Date: Thu, 14 Apr 2022 11:58:23 +0000 (+0100) Subject: patch 8.2.4748: cannot use an imported function in a mapping X-Git-Tag: v8.2.4748 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8944551534b311a2d25acf6e8db235c6d906256c;p=vim patch 8.2.4748: cannot use an imported function in a mapping Problem: Cannot use an imported function in a mapping. Solution: Recognize name.Func. --- diff --git a/runtime/doc/vim9.txt b/runtime/doc/vim9.txt index 5020bcf90..b30e5f3d4 100644 --- a/runtime/doc/vim9.txt +++ b/runtime/doc/vim9.txt @@ -1720,7 +1720,15 @@ line, there can be no line break: > name # Error! echo that .name # Error! -< *:import-cycle* + +To refer to a function in an imported script in a mapping, || can be +used: > + noremap ,a :call name.Function() + +When the mapping is defined "name." will be replaced with and the +script ID of the imported script. + + *:import-cycle* The `import` commands are executed when encountered. If script A imports script B, and B (directly or indirectly) imports A, this will be skipped over. At this point items in A after "import B" will not have been processed and diff --git a/src/proto/vim9execute.pro b/src/proto/vim9execute.pro index bd6709291..80afb8536 100644 --- a/src/proto/vim9execute.pro +++ b/src/proto/vim9execute.pro @@ -6,6 +6,7 @@ int set_ref_in_funcstacks(int copyID); char_u *char_from_string(char_u *str, varnumber_T index); char_u *string_slice(char_u *str, varnumber_T first, varnumber_T last, int exclusive); int fill_partial_and_closure(partial_T *pt, ufunc_T *ufunc, ectx_T *ectx); +int may_load_script(int sid, int *loaded); typval_T *lookup_debug_var(char_u *name); int may_break_in_function(ufunc_T *ufunc); int exe_typval_instr(typval_T *tv, typval_T *rettv); diff --git a/src/scriptfile.c b/src/scriptfile.c index 7e14cdc6e..2a1f84a50 100644 --- a/src/scriptfile.c +++ b/src/scriptfile.c @@ -117,7 +117,7 @@ estack_pop(void) } /* - * Get the current value for in allocated memory. + * Get the current value for "which" in allocated memory. * "which" is ESTACK_SFILE for , ESTACK_STACK for or * ESTACK_SCRIPT for