diff options
author | Bram Moolenaar <Bram@vim.org> | 2022-03-18 15:41:17 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-03-18 15:41:17 +0000 |
commit | f35fd8e5d484be0e3fdd7c3c24f690083f91264d (patch) | |
tree | 81308317bd7d0935faa2f8acf97a581fee44c0c5 | |
parent | 61efa16932d485fc724e4b94a8e7078a176c9946 (diff) | |
download | vim-git-f35fd8e5d484be0e3fdd7c3c24f690083f91264d.tar.gz |
patch 8.2.4588: mapping with key after other matching mapping does not workv8.2.4588
Problem: Mapping with key code after other matching mapping does not work.
Solution: Change ">" to ">=". (closes #9903)
-rw-r--r-- | src/getchar.c | 12 | ||||
-rw-r--r-- | src/testdir/test_termcodes.vim | 9 | ||||
-rw-r--r-- | src/version.c | 2 |
3 files changed, 21 insertions, 2 deletions
diff --git a/src/getchar.c b/src/getchar.c index 2bc7d9dd1..505d5a979 100644 --- a/src/getchar.c +++ b/src/getchar.c @@ -2416,6 +2416,7 @@ handle_mapping( mapblock_T *mp_match; int mp_match_len = 0; int max_mlen = 0; + int want_termcode = 0; // 1 if termcode expected after max_mlen int tb_c1; int mlen; #ifdef FEAT_LANGMAP @@ -2591,9 +2592,16 @@ handle_mapping( } else // No match; may have to check for termcode at next - // character. + // character. If the first character that didn't match is + // K_SPECIAL then check for a termcode. This isn't perfect + // but should work in most cases. if (max_mlen < mlen) + { max_mlen = mlen; + want_termcode = mp->m_keys[mlen] == K_SPECIAL; + } + else if (max_mlen == mlen && mp->m_keys[mlen] == K_SPECIAL) + want_termcode = 1; } } @@ -2646,7 +2654,7 @@ handle_mapping( // May check for a terminal code when there is no mapping or only a partial // mapping. Also check if there is a full mapping with <Esc>, unless timed // out, since that is nearly always a partial match with a terminal code. - if ((mp == NULL || max_mlen > mp_match_len + if ((mp == NULL || max_mlen + want_termcode > mp_match_len || (mp_match_len == 1 && *mp->m_keys == ESC && !*timedout)) && keylen != KEYLEN_PART_MAP) { diff --git a/src/testdir/test_termcodes.vim b/src/testdir/test_termcodes.vim index 76028e426..661917228 100644 --- a/src/testdir/test_termcodes.vim +++ b/src/testdir/test_termcodes.vim @@ -2111,6 +2111,15 @@ func Test_modifyOtherKeys_ambiguous_mapping() unmap <C-J> unmap <C-J>x + + " if a special character is following there should be a check for a termcode + nnoremap s aX<Esc> + nnoremap s<BS> aY<Esc> + set t_kb= + call setline(1, 'x') + call feedkeys("s\x08", 'Lx!') + call assert_equal('xY', getline(1)) + set timeoutlen& bwipe! endfunc diff --git a/src/version.c b/src/version.c index 5cb21e832..6c59f951c 100644 --- a/src/version.c +++ b/src/version.c @@ -751,6 +751,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 4588, +/**/ 4587, /**/ 4586, |