aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/terminal.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/terminal.c')
-rw-r--r--src/nvim/terminal.c26
1 files changed, 21 insertions, 5 deletions
diff --git a/src/nvim/terminal.c b/src/nvim/terminal.c
index fc02d9d53a..c23aff00cb 100644
--- a/src/nvim/terminal.c
+++ b/src/nvim/terminal.c
@@ -82,6 +82,7 @@ typedef struct terminal_state {
int save_rd; // saved value of RedrawingDisabled
bool close;
bool got_bsl; // if the last input was <C-\>
+ bool got_bsl_o; // if left terminal mode with <c-\><c-o>
} TerminalState;
#ifdef INCLUDE_GENERATED_DECLARATIONS
@@ -388,12 +389,11 @@ void terminal_check_size(Terminal *term)
}
/// Implements MODE_TERMINAL state. :help Terminal-mode
-void terminal_enter(void)
+bool terminal_enter(void)
{
buf_T *buf = curbuf;
assert(buf->terminal); // Should only be called when curbuf has a terminal.
- TerminalState state, *s = &state;
- memset(s, 0, sizeof(TerminalState));
+ TerminalState s[1] = { 0 };
s->term = buf->terminal;
stop_insert_mode = false;
@@ -443,7 +443,9 @@ void terminal_enter(void)
s->state.check = terminal_check;
state_enter(&s->state);
- restart_edit = 0;
+ if (!s->got_bsl_o) {
+ restart_edit = 0;
+ }
State = save_state;
RedrawingDisabled = s->save_rd;
apply_autocmds(EVENT_TERMLEAVE, NULL, NULL, false, curbuf);
@@ -467,7 +469,11 @@ void terminal_enter(void)
if (curbuf->terminal == s->term && !s->close) {
terminal_check_cursor();
}
- unshowmode(true);
+ if (restart_edit) {
+ showmode();
+ } else {
+ unshowmode(true);
+ }
ui_busy_stop();
if (s->close) {
bool wipe = s->term->buf_handle != 0;
@@ -477,6 +483,8 @@ void terminal_enter(void)
do_cmdline_cmd("bwipeout!");
}
}
+
+ return s->got_bsl_o;
}
static void terminal_check_cursor(void)
@@ -564,6 +572,14 @@ static int terminal_execute(VimState *state, int key)
}
FALLTHROUGH;
+ case Ctrl_O:
+ if (s->got_bsl) {
+ s->got_bsl_o = true;
+ restart_edit = 'I';
+ return 0;
+ }
+ FALLTHROUGH;
+
default:
if (key == Ctrl_BSL && !s->got_bsl) {
s->got_bsl = true;