Skip to content

Commit fafb4b1

Browse files
committed
patch 8.1.2159: some mappings are listed twice
Problem: Some mappings are listed twice. Solution: Skip mappings duplicated for modifyOtherKeys. (closes #5064)
1 parent 17efc7f commit fafb4b1

3 files changed

Lines changed: 31 additions & 6 deletions

File tree

src/map.c

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ do_map(
554554
for ( ; mp != NULL && !got_int; mp = mp->m_next)
555555
{
556556
// check entries with the same mode
557-
if ((mp->m_mode & mode) != 0)
557+
if (!mp->m_simplified && (mp->m_mode & mode) != 0)
558558
{
559559
if (!haskey) // show all entries
560560
{
@@ -599,15 +599,19 @@ do_map(
599599
for (mp = *mpp; mp != NULL && !got_int; mp = *mpp)
600600
{
601601

602-
if (!(mp->m_mode & mode)) // skip entries with wrong mode
602+
if ((mp->m_mode & mode) == 0)
603603
{
604+
// skip entries with wrong mode
604605
mpp = &(mp->m_next);
605606
continue;
606607
}
607608
if (!haskey) // show all entries
608609
{
609-
showmap(mp, map_table != maphash);
610-
did_it = TRUE;
610+
if (!mp->m_simplified)
611+
{
612+
showmap(mp, map_table != maphash);
613+
did_it = TRUE;
614+
}
611615
}
612616
else // do we have a match?
613617
{
@@ -643,8 +647,11 @@ do_map(
643647
}
644648
else if (!hasarg) // show matching entry
645649
{
646-
showmap(mp, map_table != maphash);
647-
did_it = TRUE;
650+
if (!mp->m_simplified)
651+
{
652+
showmap(mp, map_table != maphash);
653+
did_it = TRUE;
654+
}
648655
}
649656
else if (n != len) // new entry is ambiguous
650657
{

src/testdir/test_mapping.vim

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,3 +442,19 @@ func Test_error_in_map_expr()
442442
call delete('Xtest.vim')
443443
exe buf .. 'bwipe!'
444444
endfunc
445+
446+
func Test_list_mappings()
447+
inoremap <C-M> CtrlM
448+
inoremap <A-S> AltS
449+
inoremap <S-/> ShiftSlash
450+
call assert_equal([
451+
\ 'i <S-/> * ShiftSlash',
452+
\ 'i <M-S> * AltS',
453+
\ 'i <C-M> * CtrlM',
454+
\], execute('imap')->trim()->split("\n"))
455+
iunmap <C-M>
456+
iunmap <A-S>
457+
call assert_equal(['i <S-/> * ShiftSlash'], execute('imap')->trim()->split("\n"))
458+
iunmap <S-/>
459+
call assert_equal(['No mapping found'], execute('imap')->trim()->split("\n"))
460+
endfunc

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -753,6 +753,8 @@ static char *(features[]) =
753753

754754
static int included_patches[] =
755755
{ /* Add new patch number below this line */
756+
/**/
757+
2159,
756758
/**/
757759
2158,
758760
/**/

0 commit comments

Comments
 (0)