mirror of
https://github.com/neovim/neovim.git
synced 2026-09-04 21:30:35 +00:00
fix(ui2): ui2 misinterprets getchar() input as pager_char (CR) #41465
Problem: `vim.on_key()` callbacks are invoked for keys that `getchar()` consumes, which never reach the main loop, and there is no way to tell such a key apart. With ui2 the `on_key` handler activated after interactive cmdline, handles it as `pager_char` (thus enters the ui2 pager). Solution: Skip `vim.on_key()` callbacks during `getchar()`/`getcharstr()`.
This commit is contained in:
@@ -2102,7 +2102,7 @@ describe('lua stdlib', function()
|
||||
eq('/', exec_lua([[return _G.ctrl_c_cmdtype]]))
|
||||
end)
|
||||
|
||||
it('callback is not invoked recursively #30752', function()
|
||||
it('not invoked recursively #30752', function()
|
||||
local screen = Screen.new(60, 10)
|
||||
exec_lua([[
|
||||
vim.on_key(function(key, typed)
|
||||
@@ -2140,6 +2140,21 @@ describe('lua stdlib', function()
|
||||
]])
|
||||
end)
|
||||
|
||||
it('not invoked for keys consumed by getchar() #40010', function()
|
||||
exec_lua(function()
|
||||
_G.typed = {}
|
||||
vim.on_key(function(_, typed)
|
||||
table.insert(_G.typed, vim.fn.keytrans(typed))
|
||||
end)
|
||||
vim.keymap.set('n', '<M-m>', function()
|
||||
_G.got = vim.fn.getchar()
|
||||
end)
|
||||
end)
|
||||
feed('<M-m><CR>')
|
||||
eq(13, exec_lua('return _G.got'))
|
||||
eq({ '<M-m>' }, exec_lua('return _G.typed'))
|
||||
end)
|
||||
|
||||
it('can discard input', function()
|
||||
-- discard the first key produced by every other 'x' key typed
|
||||
exec_lua [[
|
||||
|
||||
Reference in New Issue
Block a user