aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/nvim/getchar.c17
-rw-r--r--src/nvim/testdir/test_mapping.vim16
2 files changed, 27 insertions, 6 deletions
diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c
index 89a9a1ea95..b25c59636f 100644
--- a/src/nvim/getchar.c
+++ b/src/nvim/getchar.c
@@ -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;
diff --git a/src/nvim/testdir/test_mapping.vim b/src/nvim/testdir/test_mapping.vim
index a9500f8f77..c46336460d 100644
--- a/src/nvim/testdir/test_mapping.vim
+++ b/src/nvim/testdir/test_mapping.vim
@@ -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'])