diff options
author | glacambre <code@lacamb.re> | 2019-04-08 01:13:43 +0200 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2019-04-08 01:13:43 +0200 |
commit | d928b036dc2be8f043545c0d7e2a2b2285528aaa (patch) | |
tree | c8182e15649721cdb6d2be68439cfcee02253f9f /src/nvim/terminal.c | |
parent | 11bf89e3b58be1dd534b4ea49b1988150cf7d4b8 (diff) | |
download | rneovim-d928b036dc2be8f043545c0d7e2a2b2285528aaa.tar.gz rneovim-d928b036dc2be8f043545c0d7e2a2b2285528aaa.tar.bz2 rneovim-d928b036dc2be8f043545c0d7e2a2b2285528aaa.zip |
:stopinsert should leave terminal-mode #9856
Problem: Calling :stopinsert from RPC while in terminal-mode does not
go back to normal-mode.
Solution: Implement a check() handler for state_enter(), adapted from
insert_check().
Fix #7807
Diffstat (limited to 'src/nvim/terminal.c')
-rw-r--r-- | src/nvim/terminal.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/nvim/terminal.c b/src/nvim/terminal.c index 43beb684da..79b0df842f 100644 --- a/src/nvim/terminal.c +++ b/src/nvim/terminal.c @@ -403,6 +403,7 @@ void terminal_enter(void) redraw(false); s->state.execute = terminal_execute; + s->state.check = terminal_check; state_enter(&s->state); restart_edit = 0; @@ -427,6 +428,19 @@ void terminal_enter(void) } } +// Function executed before each iteration of terminal mode. +// Return: +// 1 if the iteration should continue normally +// 0 if the main loop must exit +static int terminal_check(VimState *state) +{ + if (stop_insert_mode) { + stop_insert_mode = false; + return 0; + } + return 1; +} + static int terminal_execute(VimState *state, int key) { TerminalState *s = (TerminalState *)state; |