0
0
mirror of https://github.com/vim/vim.git synced 2025-09-26 04:04:07 -04:00

patch 8.2.4504: when there is a partially matching map full map may not work

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)
This commit is contained in:
Bram Moolenaar
2022-03-04 19:22:36 +00:00
parent 6aca4d3c2b
commit 196c3850db
3 changed files with 21 additions and 2 deletions

View File

@@ -2598,7 +2598,7 @@ handle_mapping(
} }
// If no partly match found, use the longest full match. // 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; mp = mp_match;
keylen = mp_match_len; keylen = mp_match_len;
@@ -2643,7 +2643,7 @@ handle_mapping(
max_mlen = mlen + 1; 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; int save_keylen = keylen;

View File

@@ -2098,6 +2098,23 @@ func Test_modifyOtherKeys_mapped()
set timeoutlen& set timeoutlen&
endfunc 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, " Whether Shift-Tab sends "ESC [ Z" or "ESC [ 27 ; 2 ; 9 ~" is unpredictable,
" both should work. " both should work.
func Test_modifyOtherKeys_shift_tab() func Test_modifyOtherKeys_shift_tab()

View File

@@ -754,6 +754,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
4504,
/**/ /**/
4503, 4503,
/**/ /**/