Reset stop_insert_mode in terminal_enter rather than terminal_check

Problem: Using `:stopinsert` while in normal mode in a terminal buffer
prevents neovim from entering insert mode.

Solution: Move `stop_insert_mode = false` from terminal_check to
terminal_enter to be consistent with edit.c, as suggested by bfredl in
 #9889.

Closes https://github.com/neovim/neovim/issues/9889.
This commit is contained in:
glacambre
2019-04-19 07:49:05 +02:00
committed by Björn Linse
parent 773bdd41ec
commit b3fd83a0ea
2 changed files with 10 additions and 1 deletions

View File

@@ -374,6 +374,7 @@ void terminal_enter(void)
TerminalState state, *s = &state;
memset(s, 0, sizeof(TerminalState));
s->term = buf->terminal;
stop_insert_mode = false;
// Ensure the terminal is properly sized. Ideally window size management
// code should always have resized the terminal already, but check here to
@@ -435,7 +436,6 @@ void terminal_enter(void)
static int terminal_check(VimState *state)
{
if (stop_insert_mode) {
stop_insert_mode = false;
return 0;
}
return 1;

View File

@@ -106,6 +106,15 @@ describe(':terminal', function()
command('stopinsert')
eq({ blocking=false, mode='n' }, nvim('get_mode'))
end)
it(':stopinsert in normal mode doesn\'t break insert mode #9889', function()
command(':terminal')
eq({ blocking=false, mode='n' }, nvim('get_mode'))
command(':stopinsert')
eq({ blocking=false, mode='n' }, nvim('get_mode'))
feed('a')
eq({ blocking=false, mode='t' }, nvim('get_mode'))
end)
end)
describe(':terminal (with fake shell)', function()