mirror of
https://github.com/neovim/neovim
synced 2025-07-18 18:21:46 +00:00
fix(event-loop): process input before events (#27358)
Problem: When nvim_input is followed immediately by non-fast events on RPC, both events and input are available after the polling done by the os_inchar() in state_enter(), but state_enter() then chooses to process events even if input is available, which is inconsistent with state_handle_k_event() that stops processing events once input is available. Solution: Also check for available input after the os_inchar() in state_enter().
This commit is contained in:
@ -79,7 +79,7 @@ getkey:
|
|||||||
// mapping engine.
|
// mapping engine.
|
||||||
os_inchar(NULL, 0, -1, typebuf.tb_change_cnt, main_loop.events);
|
os_inchar(NULL, 0, -1, typebuf.tb_change_cnt, main_loop.events);
|
||||||
// If an event was put into the queue, we send K_EVENT directly.
|
// If an event was put into the queue, we send K_EVENT directly.
|
||||||
if (!multiqueue_empty(main_loop.events)) {
|
if (!input_available() && !multiqueue_empty(main_loop.events)) {
|
||||||
key = K_EVENT;
|
key = K_EVENT;
|
||||||
} else {
|
} else {
|
||||||
goto getkey;
|
goto getkey;
|
||||||
|
@ -95,6 +95,14 @@ describe('API', function()
|
|||||||
assert_alive()
|
assert_alive()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it('input is processed first when followed immediately by non-fast events', function()
|
||||||
|
api.nvim_set_current_line('ab')
|
||||||
|
async_meths.nvim_input('x')
|
||||||
|
async_meths.nvim_exec_lua('_G.res1 = vim.api.nvim_get_current_line()', {})
|
||||||
|
async_meths.nvim_exec_lua('_G.res2 = vim.api.nvim_get_current_line()', {})
|
||||||
|
eq({ 'b', 'b' }, exec_lua('return { _G.res1, _G.res2 }'))
|
||||||
|
end)
|
||||||
|
|
||||||
it('does not set CA_COMMAND_BUSY #7254', function()
|
it('does not set CA_COMMAND_BUSY #7254', function()
|
||||||
command('split')
|
command('split')
|
||||||
command('autocmd WinEnter * startinsert')
|
command('autocmd WinEnter * startinsert')
|
||||||
|
Reference in New Issue
Block a user