vim-patch:8.1.2159: some mappings are listed twice

Problem:    Some mappings are listed twice.
Solution:   Skip mappings duplicated for modifyOtherKeys. (closes vim/vim#5064)
fafb4b18cd
This commit is contained in:
zeertzjq 2022-03-31 21:06:34 +08:00
parent 7029b4b44a
commit c3634a0261
2 changed files with 27 additions and 6 deletions

View File

@ -3065,7 +3065,7 @@ int buf_do_map(int maptype, MapArguments *args, int mode, bool is_abbrev, buf_T
}
for (; mp != NULL && !got_int; mp = mp->m_next) {
// check entries with the same mode
if ((mp->m_mode & mode) != 0) {
if (!mp->m_simplified && (mp->m_mode & mode) != 0) {
if (!has_lhs) { // show all entries
showmap(mp, true);
did_local = true;
@ -3100,13 +3100,16 @@ int buf_do_map(int maptype, MapArguments *args, int mode, bool is_abbrev, buf_T
mpp = &(map_table[hash]);
}
for (mp = *mpp; mp != NULL && !got_int; mp = *mpp) {
if (!(mp->m_mode & mode)) { // skip entries with wrong mode
if ((mp->m_mode & mode) == 0) {
// skip entries with wrong mode
mpp = &(mp->m_next);
continue;
}
if (!has_lhs) { // show all entries
showmap(mp, map_table != maphash);
did_it = true;
if (!mp->m_simplified) {
showmap(mp, map_table != maphash);
did_it = true;
}
} else { // do we have a match?
if (round) { // second round: Try unmap "rhs" string
n = (int)STRLEN(mp->m_str);
@ -3132,8 +3135,10 @@ int buf_do_map(int maptype, MapArguments *args, int mode, bool is_abbrev, buf_T
mp->m_mode &= ~mode;
did_it = true; // remember we did something
} else if (!has_rhs) { // show matching entry
showmap(mp, map_table != maphash);
did_it = true;
if (!mp->m_simplified) {
showmap(mp, map_table != maphash);
did_it = true;
}
} else if (n != len) { // new entry is ambiguous
mpp = &(mp->m_next);
continue;

View File

@ -429,6 +429,22 @@ func Test_error_in_map_expr()
exe buf .. 'bwipe!'
endfunc
func Test_list_mappings()
inoremap <C-M> CtrlM
inoremap <A-S> AltS
inoremap <S-/> ShiftSlash
call assert_equal([
\ 'i <S-/> * ShiftSlash',
\ 'i <M-S> * AltS',
\ 'i <C-M> * CtrlM',
\], execute('imap')->trim()->split("\n"))
iunmap <C-M>
iunmap <A-S>
call assert_equal(['i <S-/> * ShiftSlash'], execute('imap')->trim()->split("\n"))
iunmap <S-/>
call assert_equal(['No mapping found'], execute('imap')->trim()->split("\n"))
endfunc
func Test_expr_map_gets_cursor()
new
call setline(1, ['one', 'some w!rd'])