patch 9.1.0033: Insert mode not stopped if closing prompt buffer modifies hidden buffer
Commit: https://github.com/vim/vim/commit/96958366ad6159efe708b694055320ed19357e61 Author: zeertzjq <[email protected]> Date: Tue Jan 16 17:19:59 2024 +0100 patch 9.1.0033: Insert mode not stopped if closing prompt buffer modifies hidden buffer Problem: Insert mode not stopped if an autocommand modifies a hidden buffer while closing a prompt buffer. Solution: Don't set b_prompt_insert if stop_insert_mode is already set. (zeertzjq) closes: #13872 Signed-off-by: zeertzjq <[email protected]> Signed-off-by: Christian Brabandt <[email protected]> diff --git a/src/testdir/test_prompt_buffer.vim b/src/testdir/test_prompt_buffer.vim index d17373160..81a293db0 100644 --- a/src/testdir/test_prompt_buffer.vim +++ b/src/testdir/test_prompt_buffer.vim @@ -297,4 +297,36 @@ func Test_prompt_appending_while_hidden() call StopVimInTerminal(buf) endfunc +" Modifying a hidden buffer while closing a prompt buffer should not prevent +" stopping of Insert mode. +func Test_prompt_close_modify_hidden() + call CanTestPromptBuffer() + + let script =<< trim END + file hidden + set bufhidden=hide + enew + new prompt + set buftype=prompt + + inoremap <buffer> q <Cmd>bwipe!<CR> + autocmd BufWinLeave prompt call setbufline('hidden', 1, 'Test') + END + call writefile(script, 'XpromptCloseModifyHidden', 'D') + + let buf = RunVimInTerminal('-S XpromptCloseModifyHidden', {'rows': 10}) + call TermWait(buf) + + call term_sendkeys(buf, "a") + call WaitForAssert({-> assert_match('-- INSERT --', term_getline(buf, 10))}) + + call term_sendkeys(buf, "q") + call WaitForAssert({-> assert_notmatch('-- INSERT --', term_getline(buf, 10))}) + + call term_sendkeys(buf, ":bwipe!\<CR>") + call WaitForAssert({-> assert_equal('Test', term_getline(buf, 1))}) + + call StopVimInTerminal(buf) +endfunc + " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/version.c b/src/version.c index 2e32ae1d1..9f80e8276 100644 --- a/src/version.c +++ b/src/version.c @@ -704,6 +704,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 33, /**/ 32, /**/ diff --git a/src/window.c b/src/window.c index e53ac7158..d9d3401e6 100644 --- a/src/window.c +++ b/src/window.c @@ -2362,7 +2362,7 @@ leaving_window(win_T *win) // When leaving the window (or closing the window) was done from a // callback we need to break out of the Insert mode loop and restart Insert // mode when entering the window again. - if (State & MODE_INSERT) + if ((State & MODE_INSERT) && !stop_insert_mode) { stop_insert_mode = TRUE; if (win->w_buffer->b_prompt_insert == NUL) -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/vim_dev/E1rPmKG-00FIyt-T1%40256bit.org.
