mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
fix(event-loop): process input before events in getchar() (#32322)
Follow-up to #27358.
This commit is contained in:
parent
e4a58a7ca0
commit
4317d36669
@ -1932,7 +1932,7 @@ static void getchar_common(typval_T *argvars, typval_T *rettv, bool allow_number
|
|||||||
// Flush screen updates before blocking.
|
// Flush screen updates before blocking.
|
||||||
ui_flush();
|
ui_flush();
|
||||||
input_get(NULL, 0, -1, typebuf.tb_change_cnt, main_loop.events);
|
input_get(NULL, 0, -1, typebuf.tb_change_cnt, main_loop.events);
|
||||||
if (!multiqueue_empty(main_loop.events)) {
|
if (!input_available() && !multiqueue_empty(main_loop.events)) {
|
||||||
state_handle_k_event();
|
state_handle_k_event();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -96,12 +96,19 @@ describe('API', function()
|
|||||||
assert_alive()
|
assert_alive()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('input is processed first when followed immediately by non-fast events', function()
|
it('input is processed first if followed immediately by non-fast events', function()
|
||||||
api.nvim_set_current_line('ab')
|
api.nvim_set_current_line('ab')
|
||||||
async_meths.nvim_input('x')
|
async_meths.nvim_input('x')
|
||||||
async_meths.nvim_exec_lua('_G.res1 = vim.api.nvim_get_current_line()', {})
|
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()', {})
|
async_meths.nvim_exec_lua('_G.res2 = vim.api.nvim_get_current_line()', {})
|
||||||
eq({ 'b', 'b' }, exec_lua('return { _G.res1, _G.res2 }'))
|
eq({ 'b', 'b' }, exec_lua('return { _G.res1, _G.res2 }'))
|
||||||
|
-- Also test with getchar()
|
||||||
|
async_meths.nvim_command('let g:getchar = 1 | call getchar() | let g:getchar = 0')
|
||||||
|
eq(1, api.nvim_get_var('getchar'))
|
||||||
|
async_meths.nvim_input('x')
|
||||||
|
async_meths.nvim_exec_lua('_G.res1 = vim.g.getchar', {})
|
||||||
|
async_meths.nvim_exec_lua('_G.res2 = vim.g.getchar', {})
|
||||||
|
eq({ 0, 0 }, exec_lua('return { _G.res1, _G.res2 }'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('does not set CA_COMMAND_BUSY #7254', function()
|
it('does not set CA_COMMAND_BUSY #7254', function()
|
||||||
|
Loading…
Reference in New Issue
Block a user