mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
terminal: Don't enter terminal mode from :normal
Ref: https://github.com/junegunn/fzf.vim/issues/8#issuecomment-139209765
This commit is contained in:
parent
b7dab423ef
commit
1b1716477c
@ -254,7 +254,16 @@ edit (
|
||||
)
|
||||
{
|
||||
if (curbuf->terminal) {
|
||||
terminal_enter();
|
||||
if (ex_normal_busy) {
|
||||
// don't enter terminal mode from `ex_normal`, which can result in all
|
||||
// kinds of havoc(such as terminal mode recursiveness). Instead, set a
|
||||
// flag that allow us to force-set the value of `restart_edit` before
|
||||
// `ex_normal` returns
|
||||
restart_edit = 'i';
|
||||
force_restart_edit = true;
|
||||
} else {
|
||||
terminal_enter();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -7624,6 +7624,10 @@ void update_topline_cursor(void)
|
||||
*/
|
||||
static void ex_normal(exarg_T *eap)
|
||||
{
|
||||
if (curbuf->terminal) {
|
||||
EMSG("Can't re-enter normal mode from terminal mode");
|
||||
return;
|
||||
}
|
||||
int save_msg_scroll = msg_scroll;
|
||||
int save_restart_edit = restart_edit;
|
||||
int save_msg_didout = msg_didout;
|
||||
@ -7715,7 +7719,14 @@ static void ex_normal(exarg_T *eap)
|
||||
|
||||
--ex_normal_busy;
|
||||
msg_scroll = save_msg_scroll;
|
||||
restart_edit = save_restart_edit;
|
||||
if (force_restart_edit) {
|
||||
force_restart_edit = false;
|
||||
} else {
|
||||
// some function called was aware of ex_normal and decided to override the
|
||||
// value of restart_edit anyway. So far only used in terminal mode(see
|
||||
// terminal_enter() in edit.c)
|
||||
restart_edit = save_restart_edit;
|
||||
}
|
||||
p_im = save_insertmode;
|
||||
finish_op = save_finish_op;
|
||||
opcount = save_opcount;
|
||||
|
@ -823,6 +823,8 @@ EXTERN int no_u_sync INIT(= 0); /* Don't call u_sync() */
|
||||
EXTERN int u_sync_once INIT(= 0); /* Call u_sync() once when evaluating
|
||||
an expression. */
|
||||
|
||||
EXTERN bool force_restart_edit INIT(= false); // force restart_edit after
|
||||
// ex_normal returns
|
||||
EXTERN int restart_edit INIT(= 0); /* call edit when next cmd finished */
|
||||
EXTERN int arrow_used; /* Normally FALSE, set to TRUE after
|
||||
* hitting cursor key in insert mode.
|
||||
|
Loading…
Reference in New Issue
Block a user