vim-patch:9.2.0967: hit-enter prompt eats keys from a running mapping (#41359)

Problem:  The hit-enter prompt fires whenever a message scrolls the screen.
          When this happens while a mapping is being processed, it consumes
          the mapping's next key, causing unexpected behavior for users.
Solution: Similar to what 9.1.1969 did for stuffed characters, skip the
          hit-enter prompt when there are still keys pending from a mapping
          in the typeahead buffer.

related: neovim/neovim#38298
related: neovim/neovim#20635
related: neovim/neovim#30890
closes:  vim/vim#20753

AI assisted.

6025ea9e02

Co-authored-by: XiaowenHu96 <me@xiaowenhu.com>
This commit is contained in:
zeertzjq
2026-08-18 09:23:34 +08:00
committed by GitHub
parent bce3bf06a3
commit 82c751db4e
3 changed files with 54 additions and 4 deletions

View File

@@ -889,6 +889,27 @@ describe('messages', function()
]])
end)
-- oldtest: Test_hit_enter_no_eat_mapped_keys()
it('hit-enter prompt does not eat keys from a mapping', function()
screen = Screen.new(75, 10)
exec([[
set ruler more
call setline(1, range(1, 20))
" The 8-line :echo scrolls the screen and would raise a hit-enter prompt;
" the mapping then runs "gg" to move the cursor to line 1.
nnoremap X :echo "a\nb\nc\nd\ne\nf\ng\nh"<CR>gg
normal! 10G
]])
t.eq({ mode = 'n', blocking = false }, api.nvim_get_mode())
t.eq({ 10, 0 }, api.nvim_win_get_cursor(0))
feed('X')
-- Without the fix the hit-enter prompt eats the mapping's "g" keys and the
-- cursor stays put. With the fix "gg" runs and moves the cursor to line 1.
t.eq({ mode = 'n', blocking = false }, api.nvim_get_mode())
t.eq({ 1, 0 }, api.nvim_win_get_cursor(0))
end)
-- oldtest: Test_fileinfo_after_last_bd()
it('fileinfo is shown after :bd on last listed buffer', function()
screen = Screen.new(50, 10)