summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/autocmd.c5
-rw-r--r--src/structs.h1
-rw-r--r--src/testdir/test_prompt_buffer.vim11
-rw-r--r--src/version.c2
4 files changed, 19 insertions, 0 deletions
diff --git a/src/autocmd.c b/src/autocmd.c
index e5f512503a..6460fcdc64 100644
--- a/src/autocmd.c
+++ b/src/autocmd.c
@@ -1566,6 +1566,8 @@ aucmd_prepbuf(
aco->save_curwin_id = curwin->w_id;
aco->save_curbuf = curbuf;
aco->save_prevwin_id = prevwin == NULL ? 0 : prevwin->w_id;
+ aco->save_State = State;
+
if (win != NULL)
{
// There is a window for "buf" in the current tab page, make it the
@@ -1660,6 +1662,9 @@ win_found:
#ifdef FEAT_JOB_CHANNEL
// May need to stop Insert mode if we were in a prompt buffer.
leaving_window(curwin);
+ // Do not stop Insert mode when already in Insert mode before.
+ if (aco->save_State & MODE_INSERT)
+ stop_insert_mode = FALSE;
#endif
// Remove the window and frame from the tree of frames.
(void)winframe_remove(curwin, &dummy, NULL);
diff --git a/src/structs.h b/src/structs.h
index 39248a7e48..9500139080 100644
--- a/src/structs.h
+++ b/src/structs.h
@@ -4274,6 +4274,7 @@ typedef struct
bufref_T new_curbuf; // new curbuf
char_u *globaldir; // saved value of globaldir
int save_VIsual_active; // saved VIsual_active
+ int save_State; // saved State
} aco_save_T;
/*
diff --git a/src/testdir/test_prompt_buffer.vim b/src/testdir/test_prompt_buffer.vim
index 28e0d765f2..b81309c71e 100644
--- a/src/testdir/test_prompt_buffer.vim
+++ b/src/testdir/test_prompt_buffer.vim
@@ -270,6 +270,7 @@ func Test_prompt_appending_while_hidden()
func DoAppend()
call appendbufline('prompt', '$', 'Test')
+ return ''
endfunc
END
call writefile(script, 'XpromptBuffer', 'D')
@@ -282,11 +283,21 @@ func Test_prompt_appending_while_hidden()
call term_sendkeys(buf, "exit\<CR>")
call TermWait(buf)
+ call assert_notmatch('-- INSERT --', term_getline(buf, 10))
call term_sendkeys(buf, ":call DoAppend()\<CR>")
call TermWait(buf)
call assert_notmatch('-- INSERT --', term_getline(buf, 10))
+ call term_sendkeys(buf, "i")
+ call TermWait(buf)
+ call assert_match('-- INSERT --', term_getline(buf, 10))
+
+ call term_sendkeys(buf, "\<C-R>=DoAppend()\<CR>")
+ call TermWait(buf)
+ call assert_match('-- INSERT --', term_getline(buf, 10))
+
+ call term_sendkeys(buf, "\<Esc>")
call StopVimInTerminal(buf)
endfunc
diff --git a/src/version.c b/src/version.c
index 192d582787..eba3db43c3 100644
--- a/src/version.c
+++ b/src/version.c
@@ -696,6 +696,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1443,
+/**/
1442,
/**/
1441,