mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:8.2.0839: dropping modifier when putting a character back in typeahead
Problem: Dropping modifier when putting a character back in typeahead.
Solution: Add modifier to ins_char_typebuf(). (closes vim/vim#6158)
b42c0d5427
Vim's test doesn't seem to work properly as the hit-enter prompt seems
to be delayed. Add a Lua screen test.
This commit is contained in:
parent
82a13a78bb
commit
66747f18de
@ -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
|
||||
|
@ -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.
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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.
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -216,6 +216,39 @@ it('Ctrl-6 is Ctrl-^ vim-patch:8.1.2333', function()
|
||||
eq('aaa', funcs.bufname())
|
||||
end)
|
||||
|
||||
it('typing a simplifiable key at hit-enter prompt triggers mapping vim-patch:8.2.0839', function()
|
||||
local screen = Screen.new(60,8)
|
||||
screen:set_default_attr_ids({
|
||||
[1] = {bold = true, foreground = Screen.colors.Blue}, -- NonText
|
||||
[2] = {bold = true, reverse = true}, -- MsgSeparator
|
||||
[3] = {bold = true, foreground = Screen.colors.SeaGreen}, -- MoreMsg
|
||||
})
|
||||
screen:attach()
|
||||
command([[nnoremap <C-6> <Cmd>echo 'hit ctrl-6'<CR>]])
|
||||
feed_command('ls')
|
||||
screen:expect([[
|
||||
|
|
||||
{1:~ }|
|
||||
{1:~ }|
|
||||
{1:~ }|
|
||||
{2: }|
|
||||
:ls |
|
||||
1 %a "[No Name]" line 1 |
|
||||
{3:Press ENTER or type command to continue}^ |
|
||||
]])
|
||||
feed('<C-6>')
|
||||
screen:expect([[
|
||||
^ |
|
||||
{1:~ }|
|
||||
{1:~ }|
|
||||
{1:~ }|
|
||||
{1:~ }|
|
||||
{1:~ }|
|
||||
{1:~ }|
|
||||
hit ctrl-6 |
|
||||
]])
|
||||
end)
|
||||
|
||||
describe('input non-printable chars', function()
|
||||
after_each(function()
|
||||
os.remove('Xtest-overwrite')
|
||||
|
Loading…
Reference in New Issue
Block a user