normal: Don't exit CTRL-O mode after processing K_EVENT

This commit is contained in:
Björn Linse 2019-06-04 13:12:57 +02:00
parent db415bde5f
commit e50aa2a6c6
2 changed files with 17 additions and 0 deletions

View File

@ -7983,8 +7983,14 @@ static void nv_event(cmdarg_T *cap)
// not safe to perform garbage collection because there could be unreferenced
// lists or dicts being used.
may_garbage_collect = false;
bool may_restart = (restart_edit != 0);
multiqueue_process_events(main_loop.events);
finish_op = false;
if (may_restart) {
// Tricky: if restart_edit was set before the handler we are in ctrl-o mode
// but if not, the event should be allow to trigger :startinsert
cap->retval |= CA_COMMAND_BUSY; // don't call edit() now
}
}
/*

View File

@ -5,6 +5,7 @@ local eval = helpers.eval
local expect = helpers.expect
local feed = helpers.feed
local insert = helpers.insert
local meths = helpers.meths
describe('insert-mode Ctrl-O', function()
before_each(clear)
@ -40,4 +41,14 @@ describe('insert-mode Ctrl-O', function()
feed('ooo')
expect('hello oooworld')
end)
it("doesn't cancel Ctrl-O mode when processing event", function()
feed('iHello World<c-o>')
eq({mode='niI', blocking=false}, meths.get_mode()) -- fast event
eq(2, eval('1+1')) -- causes K_EVENT key
eq({mode='niI', blocking=false}, meths.get_mode()) -- still in ctrl-o mode
feed('dd')
eq({mode='i', blocking=false}, meths.get_mode()) -- left ctrl-o mode
expect('') -- executed the command
end)
end)