fix(edit): don't go to Terminal mode when stopping Insert mode (#27033)

This commit is contained in:
zeertzjq 2024-01-16 10:42:09 +08:00
parent f58c613508
commit bf4b805516
2 changed files with 10 additions and 1 deletions

View File

@ -393,7 +393,7 @@ static int insert_check(VimState *state)
Insstart_orig = Insstart;
}
if (curbuf->terminal) {
if (curbuf->terminal && !stop_insert_mode) {
// Exit Insert mode and go to Terminal mode.
stop_insert_mode = true;
restart_edit = 'I';

View File

@ -139,6 +139,15 @@ describe(':terminal', function()
eq({ blocking=false, mode='t' }, nvim('get_mode'))
eq({'InsertLeave', 'TermEnter'}, eval('g:events'))
end)
it('switching to terminal buffer immediately after :stopinsert #27031', function()
command('terminal')
command('vnew')
feed('i')
eq({ blocking = false, mode = 'i' }, nvim('get_mode'))
command('stopinsert | wincmd p')
eq({ blocking = false, mode = 'nt' }, nvim('get_mode'))
end)
end)
local function test_terminal_with_fake_shell(backslash)