summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2022-03-04 19:22:36 +0000
committerBram Moolenaar <Bram@vim.org>2022-03-04 19:22:36 +0000
commit196c3850dbe95247f7aa1b0000a5cae625a99ef2 (patch)
tree31b90ae051e63ba144486d65863f4de2ca941f44
parent6aca4d3c2bb6b60cdf51b2ab49fbec6b8f88c890 (diff)
downloadvim-git-196c3850dbe95247f7aa1b0000a5cae625a99ef2.tar.gz
patch 8.2.4504: when there is a partially matching map full map may not workv8.2.4504
Problem: When there is a partially matching map and modifyOtherKeys is active a full map may not work. Solution: Only simplify modifiers when there is no matching mapping. (closes #8792)
-rw-r--r--src/getchar.c4
-rw-r--r--src/testdir/test_termcodes.vim17
-rw-r--r--src/version.c2
3 files changed, 21 insertions, 2 deletions
diff --git a/src/getchar.c b/src/getchar.c
index 2fbbd4f6e..03d6d4d96 100644
--- a/src/getchar.c
+++ b/src/getchar.c
@@ -2598,7 +2598,7 @@ handle_mapping(
}
// If no partly match found, use the longest full match.
- if (keylen != KEYLEN_PART_MAP)
+ if (keylen != KEYLEN_PART_MAP && mp_match != NULL)
{
mp = mp_match;
keylen = mp_match_len;
@@ -2643,7 +2643,7 @@ handle_mapping(
max_mlen = mlen + 1;
}
- if ((mp == NULL || max_mlen >= mp_match_len) && keylen != KEYLEN_PART_MAP)
+ if ((mp == NULL || max_mlen > mp_match_len) && keylen != KEYLEN_PART_MAP)
{
int save_keylen = keylen;
diff --git a/src/testdir/test_termcodes.vim b/src/testdir/test_termcodes.vim
index 614c0977d..a68506c1e 100644
--- a/src/testdir/test_termcodes.vim
+++ b/src/testdir/test_termcodes.vim
@@ -2098,6 +2098,23 @@ func Test_modifyOtherKeys_mapped()
set timeoutlen&
endfunc
+func Test_modifyOtherKeys_ambiguous_mapping()
+ new
+ set timeoutlen=10
+ map <C-J> a
+ map <C-J>x <Nop>
+ call setline(1, 'x')
+
+ " CTRL-J b should have trigger the <C-J> mapping and then insert "b"
+ call feedkeys(GetEscCodeCSI27('J', 5) .. "b\<Esc>", 'Lx!')
+ call assert_equal('xb', getline(1))
+
+ unmap <C-J>
+ unmap <C-J>x
+ set timeoutlen&
+ bwipe!
+endfunc
+
" Whether Shift-Tab sends "ESC [ Z" or "ESC [ 27 ; 2 ; 9 ~" is unpredictable,
" both should work.
func Test_modifyOtherKeys_shift_tab()
diff --git a/src/version.c b/src/version.c
index 6a21b8a9a..e1ca0d7e8 100644
--- a/src/version.c
+++ b/src/version.c
@@ -755,6 +755,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 4504,
+/**/
4503,
/**/
4502,