diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/getchar.c | 6 | ||||
-rw-r--r-- | src/nvim/globals.h | 3 | ||||
-rw-r--r-- | src/nvim/message.c | 2 | ||||
-rw-r--r-- | src/nvim/normal.c | 2 | ||||
-rw-r--r-- | src/nvim/terminal.c | 2 | ||||
-rw-r--r-- | src/nvim/testdir/test_messages.vim | 8 |
6 files changed, 20 insertions, 3 deletions
diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c index f92aa14c78..fbe503bcd4 100644 --- a/src/nvim/getchar.c +++ b/src/nvim/getchar.c @@ -1499,6 +1499,8 @@ int vgetc(void) static size_t last_vgetc_recorded_len = 0; mod_mask = 0; + vgetc_mod_mask = 0; + vgetc_char = 0; // last_recorded_len can be larger than last_vgetc_recorded_len // if peeking records more @@ -1624,6 +1626,10 @@ int vgetc(void) // A modifier was not used for a mapping, apply it to ASCII // keys. Shift would already have been applied. + // Remember the character and mod_mask from before, in some + // cases they are put back in the typeahead buffer. + vgetc_mod_mask = mod_mask; + vgetc_char = c; c = merge_modifiers(c); // If mappings are enabled (i.e., not Ctrl-v) and the user directly typed diff --git a/src/nvim/globals.h b/src/nvim/globals.h index e07a0e22ca..6e0b445656 100644 --- a/src/nvim/globals.h +++ b/src/nvim/globals.h @@ -129,6 +129,9 @@ typedef off_t off_T; // held down based on the MOD_MASK_* symbols that are read first. EXTERN int mod_mask INIT(= 0); // current key modifiers +// The value of "mod_mask" and the unmodified character before calling merge_modifiers(). +EXTERN int vgetc_mod_mask INIT(= 0); +EXTERN int vgetc_char INIT(= 0); // Cmdline_row is the row where the command line starts, just below the // last window. diff --git a/src/nvim/message.c b/src/nvim/message.c index 6708001495..90af920396 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -1214,7 +1214,7 @@ void wait_return(int redraw) } else if (vim_strchr((char_u *)"\r\n ", c) == NULL && c != Ctrl_C) { // Put the character back in the typeahead buffer. Don't use the // stuff buffer, because lmaps wouldn't work. - ins_char_typebuf(c, mod_mask); + ins_char_typebuf(vgetc_char, vgetc_mod_mask); do_redraw = true; // need a redraw even though there is // typeahead } diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 73ea995d8f..a04316f5e4 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -995,7 +995,7 @@ static int normal_execute(VimState *state, int key) // restart automatically. // Insert the typed character in the typeahead buffer, so that it can // be mapped in Insert mode. Required for ":lmap" to work. - int len = ins_char_typebuf(s->c, mod_mask); + int len = ins_char_typebuf(vgetc_char, vgetc_mod_mask); // When recording and gotchars() was called the character will be // recorded again, remove the previous recording. diff --git a/src/nvim/terminal.c b/src/nvim/terminal.c index fd870361c7..5f536c0b7a 100644 --- a/src/nvim/terminal.c +++ b/src/nvim/terminal.c @@ -1348,7 +1348,7 @@ static bool send_mouse_event(Terminal *term, int c) } end: - ins_char_typebuf(c, mod_mask); + ins_char_typebuf(vgetc_char, vgetc_mod_mask); return true; } diff --git a/src/nvim/testdir/test_messages.vim b/src/nvim/testdir/test_messages.vim index 82c4cc128b..2e9b0a8531 100644 --- a/src/nvim/testdir/test_messages.vim +++ b/src/nvim/testdir/test_messages.vim @@ -112,6 +112,14 @@ func Test_echospace() set ruler& showcmd& endfunc +func Test_mapping_at_hit_return_prompt() + nnoremap <C-B> :echo "hit ctrl-b"<CR> + call feedkeys(":ls\<CR>", "xt") + call feedkeys("\<C-B>", "xt") + call assert_match('hit ctrl-b', Screenline(&lines - 1)) + nunmap <C-B> +endfunc + func Test_quit_long_message() CheckScreendump |