diff options
author | zeertzjq <zeertzjq@outlook.com> | 2022-05-05 07:23:27 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-05 07:23:27 +0800 |
commit | beb8f484891f5361cc2ee757b93b4e4aba228612 (patch) | |
tree | d8055e292e6c3a6936f01e137f6ea87add838dbf /src/nvim/message.c | |
parent | 6798f1fab0244ee535675fa9100945eec074e6e4 (diff) | |
download | rneovim-beb8f484891f5361cc2ee757b93b4e4aba228612.tar.gz rneovim-beb8f484891f5361cc2ee757b93b4e4aba228612.tar.bz2 rneovim-beb8f484891f5361cc2ee757b93b4e4aba228612.zip |
vim-patch:8.2.4867: listing of mapping with K_SPECIAL is wrong (#18419)
Problem: Listing of mapping with K_SPECIAL is wrong.
Solution: Adjust escaping of special characters. (closes vim/vim#10351)
https://github.com/vim/vim/commit/ac402f4d64bec6b6efd809fef52f5b34627bf947
Avoid overshadowing.
Cherry-pick Test_list_mapping() from Vim patches 8.2.{0148,2994}.
Fix rhs_is_noop.
Diffstat (limited to 'src/nvim/message.c')
-rw-r--r-- | src/nvim/message.c | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/src/nvim/message.c b/src/nvim/message.c index f0ef4e1d4f..cdcbcc6700 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -1671,11 +1671,13 @@ const char *str2special(const char **const sp, const bool replace_spaces, const { static char buf[7]; - // Try to un-escape a multi-byte character. Return the un-escaped - // string if it is a multi-byte character. - const char *const p = mb_unescape(sp); - if (p != NULL) { - return p; + { + // Try to un-escape a multi-byte character. Return the un-escaped + // string if it is a multi-byte character. + const char *const p = mb_unescape(sp); + if (p != NULL) { + return p; + } } const char *str = *sp; @@ -1698,18 +1700,24 @@ const char *str2special(const char **const sp, const bool replace_spaces, const } if (!IS_SPECIAL(c)) { - const int len = utf_ptr2len((const char_u *)str); + *sp = str; + // Try to un-escape a multi-byte character after modifiers. + const char *p = mb_unescape(sp); - // Check for an illegal byte. - if (MB_BYTE2LEN((uint8_t)(*str)) > len) { - transchar_nonprint(curbuf, (char_u *)buf, c); - *sp = str + 1; - return buf; + if (p == NULL) { + const int len = utf_ptr2len((const char_u *)str); + // Check for an illegal byte. + if (MB_BYTE2LEN((uint8_t)(*str)) > len) { + transchar_nonprint(curbuf, (char_u *)buf, c); + *sp = str + 1; + return buf; + } + *sp = str + len; + p = str; } - // Since 'special' is TRUE the multi-byte character 'c' will be + // Since 'special' is true the multi-byte character 'c' will be // processed by get_special_key_name(). - c = utf_ptr2char((const char_u *)str); - *sp = str + len; + c = utf_ptr2char((const char_u *)p); } else { *sp = str + 1; } |