Patch 9.0.1439

6 views
Skip to first unread message

Bram Moolenaar

unread,
Apr 2, 2023, 5:06:41 PM4/2/23
to vim...@googlegroups.com

Patch 9.0.1439
Problem: Start Insert mode when accessing a hidden prompt buffer.
Solution: Call leaving_window() in aucmd_restbuf(). (Thorben Tröbst,
closes #12148, closes #12147)
Files: src/autocmd.c, src/window.c, src/proto/window.pro,
src/testdir/test_prompt_buffer.vim


*** ../vim-9.0.1438/src/autocmd.c 2023-03-12 21:20:51.437254187 +0000
--- src/autocmd.c 2023-04-02 22:04:14.918501302 +0100
***************
*** 1657,1663 ****
}
}
win_found:
!
// Remove the window and frame from the tree of frames.
(void)winframe_remove(curwin, &dummy, NULL);
win_remove(curwin, NULL);
--- 1657,1666 ----
}
}
win_found:
! #ifdef FEAT_JOB_CHANNEL
! // May need to stop Insert mode if we were in a prompt buffer.
! leaving_window(curwin);
! #endif
// Remove the window and frame from the tree of frames.
(void)winframe_remove(curwin, &dummy, NULL);
win_remove(curwin, NULL);
*** ../vim-9.0.1438/src/window.c 2023-03-07 17:13:47.321107768 +0000
--- src/window.c 2023-04-02 21:53:59.557421392 +0100
***************
*** 2292,2298 ****
}

#ifdef FEAT_JOB_CHANNEL
! static void
leaving_window(win_T *win)
{
// Only matters for a prompt window.
--- 2292,2298 ----
}

#ifdef FEAT_JOB_CHANNEL
! void
leaving_window(win_T *win)
{
// Only matters for a prompt window.
*** ../vim-9.0.1438/src/proto/window.pro 2022-11-22 12:40:44.062427876 +0000
--- src/proto/window.pro 2023-04-02 22:03:45.410605841 +0100
***************
*** 13,18 ****
--- 13,19 ----
int make_windows(int count, int vertical);
void win_move_after(win_T *win1, win_T *win2);
void win_equal(win_T *next_curwin, int current, int dir);
+ void leaving_window(win_T *win);
void entering_window(win_T *win);
void curwin_init(void);
void close_windows(buf_T *buf, int keep_curwin);
*** ../vim-9.0.1438/src/testdir/test_prompt_buffer.vim 2022-10-06 19:49:09.561466199 +0100
--- src/testdir/test_prompt_buffer.vim 2023-04-02 22:03:09.246740858 +0100
***************
*** 252,255 ****
--- 252,293 ----
call StopVimInTerminal(buf)
endfunc

+ func Test_prompt_appending_while_hidden()
+ call CanTestPromptBuffer()
+
+ let script =<< trim END
+ new prompt
+ set buftype=prompt
+ set bufhidden=hide
+
+ func s:TextEntered(text)
+ if a:text == 'exit'
+ close
+ endif
+ echowin 'Entered:' a:text
+ endfunc
+ call prompt_setcallback(bufnr(), function('s:TextEntered'))
+
+ func DoAppend()
+ call appendbufline('prompt', '$', 'Test')
+ endfunc
+ END
+ call writefile(script, 'XpromptBuffer', 'D')
+
+ let buf = RunVimInTerminal('-S XpromptBuffer', {'rows': 10})
+ call TermWait(buf)
+
+ call term_sendkeys(buf, "asomething\<CR>")
+ call TermWait(buf)
+
+ call term_sendkeys(buf, "exit\<CR>")
+ call TermWait(buf)
+
+ call term_sendkeys(buf, ":call DoAppend()\<CR>")
+ call TermWait(buf)
+ call assert_notmatch('-- INSERT --', term_getline(buf, 10))
+
+ call StopVimInTerminal(buf)
+ endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
*** ../vim-9.0.1438/src/version.c 2023-04-02 20:29:33.741597887 +0100
--- src/version.c 2023-04-02 21:56:32.396906337 +0100
***************
*** 697,698 ****
--- 697,700 ----
{ /* Add new patch number below this line */
+ /**/
+ 1439,
/**/

--
With sufficient thrust, pigs fly just fine.
-- RFC 1925

/// 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 ///
Reply all
Reply to author
Forward
0 new messages