Patch 9.0.1582
Problem: :stopinsert may not work in a popup close handler. (Ben Jackson)
Solution: Restore stop_insert_mode when appropriate. (closes #12452,
closes #12434)
Files: src/autocmd.c, src/testdir/test_quickfix.vim
*** ../vim-9.0.1581/src/autocmd.c 2023-05-20 14:06:56.669542805 +0100
--- src/autocmd.c 2023-05-27 14:05:37.740383958 +0100
***************
*** 1657,1667 ****
}
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);
--- 1657,1669 ----
}
win_found:
#ifdef FEAT_JOB_CHANNEL
+ ;
+ int save_stop_insert_mode = stop_insert_mode;
// 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 = save_stop_insert_mode;
#endif
// Remove the window and frame from the tree of frames.
(void)winframe_remove(curwin, &dummy, NULL);
*** ../vim-9.0.1581/src/testdir/test_quickfix.vim 2023-01-28 19:18:56.733720607 +0000
--- src/testdir/test_quickfix.vim 2023-05-27 14:05:37.744383958 +0100
***************
*** 6404,6408 ****
--- 6404,6431 ----
call setqflist([], 'f')
endfunc
+ " Test that setqflist() should not prevent :stopinsert from working
+ func Test_setqflist_stopinsert()
+ new
+ call setqflist([], 'f')
+ copen
+ cclose
+ func StopInsert()
+ stopinsert
+ call setqflist([{'text': 'foo'}])
+ return ''
+ endfunc
+
+ call setline(1, 'abc')
+ call cursor(1, 1)
+ call feedkeys("i\<C-R>=StopInsert()\<CR>$", 'tnix')
+ call assert_equal('foo', getqflist()[0].text)
+ call assert_equal([0, 1, 3, 0, v:maxcol], getcurpos())
+ call assert_equal(['abc'], getline(1, '$'))
+
+ delfunc StopInsert
+ call setqflist([], 'f')
+ bwipe!
+ endfunc
" vim: shiftwidth=2 sts=2 expandtab
*** ../vim-9.0.1581/src/version.c 2023-05-27 13:40:03.388087776 +0100
--- src/version.c 2023-05-27 14:09:46.367255161 +0100
***************
*** 697,698 ****
--- 697,700 ----
{ /* Add new patch number below this line */
+ /**/
+ 1582,
/**/
--
hundred-and-one symptoms of being an internet addict:
91. It's Saturday afternoon in the middle of May and you
are on computer.
/// 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 ///