Mercurial > vim
changeset 27958:ac7db4437368 v8.2.4504
patch 8.2.4504: when there is a partially matching map full map may not work
Commit: https://github.com/vim/vim/commit/196c3850dbe95247f7aa1b0000a5cae625a99ef2
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Mar 4 19:22:36 2022 +0000
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)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 04 Mar 2022 20:30:03 +0100 |
parents | 6836d57ae66e |
children | ec56a659a69a |
files | src/getchar.c src/testdir/test_termcodes.vim src/version.c |
diffstat | 3 files changed, 21 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- 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;
--- 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()