Mercurial > vim
comparison src/term.c @ 28453:862068e9e2a7 v8.2.4751
patch 8.2.4751: mapping <SID>name.Func does not work for autoload script
Commit: https://github.com/vim/vim/commit/648dd88af67c7abac31915cbf0025f97031c96c1
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Apr 14 21:36:15 2022 +0100
patch 8.2.4751: mapping <SID>name.Func does not work for autoload script
Problem: Mapping <SID>name.Func does not work for script in autoload
directory.
Solution: Use the # form for a script in the autoload directory.
(closes #10186)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 14 Apr 2022 22:45:03 +0200 |
parents | 6f753a8125f0 |
children | 4dcccb2673fe |
comparison
equal
deleted
inserted
replaced
28452:d41ef9630691 | 28453:862068e9e2a7 |
---|---|
5961 char_u *src; | 5961 char_u *src; |
5962 int do_backslash; // backslash is a special character | 5962 int do_backslash; // backslash is a special character |
5963 int do_special; // recognize <> key codes | 5963 int do_special; // recognize <> key codes |
5964 int do_key_code; // recognize raw key codes | 5964 int do_key_code; // recognize raw key codes |
5965 char_u *result; // buffer for resulting string | 5965 char_u *result; // buffer for resulting string |
5966 garray_T ga; | |
5966 | 5967 |
5967 do_backslash = (vim_strchr(p_cpo, CPO_BSLASH) == NULL); | 5968 do_backslash = (vim_strchr(p_cpo, CPO_BSLASH) == NULL); |
5968 do_special = (vim_strchr(p_cpo, CPO_SPECI) == NULL) | 5969 do_special = (vim_strchr(p_cpo, CPO_SPECI) == NULL) |
5969 || (flags & REPTERM_SPECIAL); | 5970 || (flags & REPTERM_SPECIAL); |
5970 do_key_code = (vim_strchr(p_cpo, CPO_KEYCODE) == NULL); | 5971 do_key_code = (vim_strchr(p_cpo, CPO_KEYCODE) == NULL); |
5972 src = from; | |
5971 | 5973 |
5972 /* | 5974 /* |
5973 * Allocate space for the translation. Worst case a single character is | 5975 * Allocate space for the translation. Worst case a single character is |
5974 * replaced by 6 bytes (shifted special key), plus a NUL at the end. | 5976 * replaced by 6 bytes (shifted special key), plus a NUL at the end. |
5977 * In the rare case more might be needed ga_grow() must be called again. | |
5975 */ | 5978 */ |
5976 result = alloc(STRLEN(from) * 6 + 1); | 5979 ga_init2(&ga, 1L, 100); |
5977 if (result == NULL) // out of memory | 5980 if (ga_grow(&ga, STRLEN(src) * 6 + 1) == FAIL) // out of memory |
5978 { | 5981 { |
5979 *bufp = NULL; | 5982 *bufp = NULL; |
5980 return from; | 5983 return from; |
5981 } | 5984 } |
5982 | 5985 result = ga.ga_data; |
5983 src = from; | |
5984 | 5986 |
5985 /* | 5987 /* |
5986 * Check for #n at start only: function key n | 5988 * Check for #n at start only: function key n |
5987 */ | 5989 */ |
5988 if ((flags & REPTERM_FROM_PART) && src[0] == '#' && VIM_ISDIGIT(src[1])) | 5990 if ((flags & REPTERM_FROM_PART) && src[0] == '#' && VIM_ISDIGIT(src[1])) |
6031 { | 6033 { |
6032 imported_T *imp = find_imported(src, dot - src, FALSE); | 6034 imported_T *imp = find_imported(src, dot - src, FALSE); |
6033 | 6035 |
6034 if (imp != NULL) | 6036 if (imp != NULL) |
6035 { | 6037 { |
6038 scriptitem_T *si = SCRIPT_ITEM(imp->imp_sid); | |
6039 size_t len; | |
6040 | |
6041 src = dot + 1; | |
6042 if (si->sn_autoload_prefix != NULL) | |
6043 { | |
6044 // Turn "<SID>name.Func" | |
6045 // into "scriptname#Func". | |
6046 len = STRLEN(si->sn_autoload_prefix); | |
6047 if (ga_grow(&ga, STRLEN(src) * 6 + len + 1) | |
6048 == FAIL) | |
6049 { | |
6050 ga_clear(&ga); | |
6051 *bufp = NULL; | |
6052 return from; | |
6053 } | |
6054 result = ga.ga_data; | |
6055 STRCPY(result + dlen, si->sn_autoload_prefix); | |
6056 dlen += len; | |
6057 continue; | |
6058 } | |
6036 sid = imp->imp_sid; | 6059 sid = imp->imp_sid; |
6037 src = dot + 1; | |
6038 } | 6060 } |
6039 } | 6061 } |
6040 | 6062 |
6041 result[dlen++] = K_SPECIAL; | 6063 result[dlen++] = K_SPECIAL; |
6042 result[dlen++] = (int)KS_EXTRA; | 6064 result[dlen++] = (int)KS_EXTRA; |
6046 result[dlen++] = '_'; | 6068 result[dlen++] = '_'; |
6047 continue; | 6069 continue; |
6048 } | 6070 } |
6049 } | 6071 } |
6050 #endif | 6072 #endif |
6051 | |
6052 slen = trans_special(&src, result + dlen, FSK_KEYCODE | 6073 slen = trans_special(&src, result + dlen, FSK_KEYCODE |
6053 | ((flags & REPTERM_NO_SIMPLIFY) ? 0 : FSK_SIMPLIFY), | 6074 | ((flags & REPTERM_NO_SIMPLIFY) ? 0 : FSK_SIMPLIFY), |
6054 did_simplify); | 6075 did_simplify); |
6055 if (slen) | 6076 if (slen) |
6056 { | 6077 { |