diff options
-rw-r--r-- | src/nvim/terminal.c | 2 | ||||
-rw-r--r-- | test/functional/terminal/ex_terminal_spec.lua | 9 |
2 files changed, 10 insertions, 1 deletions
diff --git a/src/nvim/terminal.c b/src/nvim/terminal.c index 79b0df842f..a802a1ffc6 100644 --- a/src/nvim/terminal.c +++ b/src/nvim/terminal.c @@ -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; diff --git a/test/functional/terminal/ex_terminal_spec.lua b/test/functional/terminal/ex_terminal_spec.lua index ca5737db7f..f3849709e3 100644 --- a/test/functional/terminal/ex_terminal_spec.lua +++ b/test/functional/terminal/ex_terminal_spec.lua @@ -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() |