Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3f71218

Browse files
authored
Merge pull request #9926 from glacambre/fix_9889
Fix #9889: stopinsert prohibiting terminal mode
2 parents 477e1a8 + b3fd83a commit 3f71218

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/nvim/terminal.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,7 @@ void terminal_enter(void)
374374
TerminalState state, *s = &state;
375375
memset(s, 0, sizeof(TerminalState));
376376
s->term = buf->terminal;
377+
stop_insert_mode = false;
377378

378379
// Ensure the terminal is properly sized. Ideally window size management
379380
// code should always have resized the terminal already, but check here to
@@ -435,7 +436,6 @@ void terminal_enter(void)
435436
static int terminal_check(VimState *state)
436437
{
437438
if (stop_insert_mode) {
438-
stop_insert_mode = false;
439439
return 0;
440440
}
441441
return 1;

test/functional/terminal/ex_terminal_spec.lua

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,15 @@ describe(':terminal', function()
106106
command('stopinsert')
107107
eq({ blocking=false, mode='n' }, nvim('get_mode'))
108108
end)
109+
110+
it(':stopinsert in normal mode doesn\'t break insert mode #9889', function()
111+
command(':terminal')
112+
eq({ blocking=false, mode='n' }, nvim('get_mode'))
113+
command(':stopinsert')
114+
eq({ blocking=false, mode='n' }, nvim('get_mode'))
115+
feed('a')
116+
eq({ blocking=false, mode='t' }, nvim('get_mode'))
117+
end)
109118
end)
110119

111120
describe(':terminal (with fake shell)', function()

0 commit comments

Comments
 (0)