aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/api
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-03-31 15:47:53 +0800
committerzeertzjq <zeertzjq@outlook.com>2022-04-29 15:51:03 +0800
commitdde4f09f51ffaf8df5cc2a81eed935e31e1f94ba (patch)
tree392ec276e38a6a980d5610060795eea730b73311 /src/nvim/api
parent188537efb32d02081c1821cb5b48fbcf59230732 (diff)
downloadrneovim-dde4f09f51ffaf8df5cc2a81eed935e31e1f94ba.tar.gz
rneovim-dde4f09f51ffaf8df5cc2a81eed935e31e1f94ba.tar.bz2
rneovim-dde4f09f51ffaf8df5cc2a81eed935e31e1f94ba.zip
vim-patch:8.1.2145: cannot map <C-H> when modifyOtherKeys is enabled
Problem: Cannot map <C-H> when modifyOtherKeys is enabled. Solution: Add the <C-H> mapping twice, both with modifier and as 0x08. Use only the first one when modifyOtherKeys has been detected. https://github.com/vim/vim/commit/459fd785e4a8d044147a3f83a5fca8748528aa84 Add REPTERM_NO_SPECIAL instead of REPTERM_SPECIAL because the meaning of "special" is different between Vim and Nvim. Omit seenModifyOtherKeys as Nvim supports attaching multiple UIs. Omit tests as they send terminal codes. Keep the behavior of API functions.
Diffstat (limited to 'src/nvim/api')
-rw-r--r--src/nvim/api/private/helpers.c5
-rw-r--r--src/nvim/api/vim.c14
2 files changed, 16 insertions, 3 deletions
diff --git a/src/nvim/api/private/helpers.c b/src/nvim/api/private/helpers.c
index 5ba4700f62..8383f29400 100644
--- a/src/nvim/api/private/helpers.c
+++ b/src/nvim/api/private/helpers.c
@@ -632,7 +632,7 @@ void modify_keymap(uint64_t channel_id, Buffer buffer, bool is_unmap, String mod
} else {
parsed_args.desc = NULL;
}
- if (parsed_args.lhs_len > MAXMAPLEN) {
+ if (parsed_args.lhs_len > MAXMAPLEN || parsed_args.alt_lhs_len > MAXMAPLEN) {
api_set_error(err, kErrorTypeValidation, "LHS exceeds maximum map length: %s", lhs.data);
goto fail_and_free;
}
@@ -1128,6 +1128,9 @@ ArrayOf(Dictionary) keymap_array(String mode, buf_T *buf, bool from_lua)
for (const mapblock_T *current_maphash = get_maphash(i, buf);
current_maphash;
current_maphash = current_maphash->m_next) {
+ if (current_maphash->m_simplified) {
+ continue;
+ }
// Check for correct mode
if (int_mode & current_maphash->m_mode) {
mapblock_fill_dict(dict, current_maphash, buffer_value, false);
diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c
index 0f9a4a0e0d..2174cd1620 100644
--- a/src/nvim/api/vim.c
+++ b/src/nvim/api/vim.c
@@ -403,9 +403,19 @@ String nvim_replace_termcodes(String str, Boolean from_part, Boolean do_lt, Bool
return (String) { .data = NULL, .size = 0 };
}
+ int flags = 0;
+ if (from_part) {
+ flags |= REPTERM_FROM_PART;
+ }
+ if (do_lt) {
+ flags |= REPTERM_DO_LT;
+ }
+ if (!special) {
+ flags |= REPTERM_NO_SPECIAL;
+ }
+
char *ptr = NULL;
- replace_termcodes((char_u *)str.data, str.size, (char_u **)&ptr,
- from_part, do_lt, special, CPO_TO_CPO_FLAGS);
+ replace_termcodes((char_u *)str.data, str.size, (char_u **)&ptr, flags, NULL, CPO_TO_CPO_FLAGS);
return cstr_as_string(ptr);
}