Patch 9.0.1443
Problem: Ending Insert mode when accessing a hidden prompt buffer.
Solution: Don't stop Insert mode when it was active before. (closes #12237)
Files: src/structs.h, src/autocmd.c, src/testdir/test_prompt_buffer.vim
*** ../vim-9.0.1442/src/structs.h 2023-03-05 13:12:28.492767233 +0000
--- src/structs.h 2023-04-09 21:55:17.492454445 +0100
***************
*** 4274,4279 ****
--- 4274,4280 ----
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;
/*
*** ../vim-9.0.1442/src/autocmd.c 2023-04-02 22:05:09.786319296 +0100
--- src/autocmd.c 2023-04-09 22:00:39.091415442 +0100
***************
*** 1566,1571 ****
--- 1566,1573 ----
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,1665 ****
--- 1662,1670 ----
#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);
*** ../vim-9.0.1442/src/testdir/test_prompt_buffer.vim 2023-04-02 22:05:09.786319296 +0100
--- src/testdir/test_prompt_buffer.vim 2023-04-09 21:28:27.252025197 +0100
***************
*** 270,275 ****
--- 270,276 ----
func DoAppend()
call appendbufline('prompt', '$', 'Test')
+ return ''
endfunc
END
call writefile(script, 'XpromptBuffer', 'D')
***************
*** 282,292 ****
--- 283,303 ----
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
*** ../vim-9.0.1442/src/version.c 2023-04-07 22:09:42.624287094 +0100
--- src/version.c 2023-04-09 21:56:50.372110313 +0100
***************
*** 697,698 ****
--- 697,700 ----
{ /* Add new patch number below this line */
+ /**/
+ 1443,
/**/
--
ARTHUR: Listen, old crone! Unless you tell us where we can buy a shrubbery,
my friend and I will ... we will say "Ni!"
CRONE: Do your worst!
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
/// Bram Moolenaar -- Br...@Moolenaar.net --
http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features --
http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims --
http://ICCF-Holland.org ///