Mercurial > vim
comparison src/term.c @ 28447:6f753a8125f0 v8.2.4748
patch 8.2.4748: cannot use an imported function in a mapping
Commit: https://github.com/vim/vim/commit/8944551534b311a2d25acf6e8db235c6d906256c
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Apr 14 12:58:23 2022 +0100
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.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 14 Apr 2022 14:00:05 +0200 |
parents | dbf6d5ea7a1f |
children | 862068e9e2a7 |
comparison
equal
deleted
inserted
replaced
28446:224455817fac | 28447:6f753a8125f0 |
---|---|
6008 if (do_special && ((flags & REPTERM_DO_LT) | 6008 if (do_special && ((flags & REPTERM_DO_LT) |
6009 || STRNCMP(src, "<lt>", 4) != 0)) | 6009 || STRNCMP(src, "<lt>", 4) != 0)) |
6010 { | 6010 { |
6011 #ifdef FEAT_EVAL | 6011 #ifdef FEAT_EVAL |
6012 /* | 6012 /* |
6013 * Replace <SID> by K_SNR <script-nr> _. | 6013 * Change <SID>Func to K_SNR <script-nr> _Func. This name is used |
6014 * for script-locla user functions. | |
6014 * (room: 5 * 6 = 30 bytes; needed: 3 + <nr> + 1 <= 14) | 6015 * (room: 5 * 6 = 30 bytes; needed: 3 + <nr> + 1 <= 14) |
6016 * Also change <SID>name.Func to K_SNR <import-script-nr> _Func. | |
6017 * Only if "name" is recognized as an import. | |
6015 */ | 6018 */ |
6016 if (STRNICMP(src, "<SID>", 5) == 0) | 6019 if (STRNICMP(src, "<SID>", 5) == 0) |
6017 { | 6020 { |
6018 if (current_sctx.sc_sid <= 0) | 6021 if (current_sctx.sc_sid <= 0) |
6019 emsg(_(e_using_sid_not_in_script_context)); | 6022 emsg(_(e_using_sid_not_in_script_context)); |
6020 else | 6023 else |
6021 { | 6024 { |
6025 char_u *dot; | |
6026 long sid = current_sctx.sc_sid; | |
6027 | |
6022 src += 5; | 6028 src += 5; |
6029 if (in_vim9script() | |
6030 && (dot = vim_strchr(src, '.')) != NULL) | |
6031 { | |
6032 imported_T *imp = find_imported(src, dot - src, FALSE); | |
6033 | |
6034 if (imp != NULL) | |
6035 { | |
6036 sid = imp->imp_sid; | |
6037 src = dot + 1; | |
6038 } | |
6039 } | |
6040 | |
6023 result[dlen++] = K_SPECIAL; | 6041 result[dlen++] = K_SPECIAL; |
6024 result[dlen++] = (int)KS_EXTRA; | 6042 result[dlen++] = (int)KS_EXTRA; |
6025 result[dlen++] = (int)KE_SNR; | 6043 result[dlen++] = (int)KE_SNR; |
6026 sprintf((char *)result + dlen, "%ld", | 6044 sprintf((char *)result + dlen, "%ld", sid); |
6027 (long)current_sctx.sc_sid); | |
6028 dlen += (int)STRLEN(result + dlen); | 6045 dlen += (int)STRLEN(result + dlen); |
6029 result[dlen++] = '_'; | 6046 result[dlen++] = '_'; |
6030 continue; | 6047 continue; |
6031 } | 6048 } |
6032 } | 6049 } |