diff options
author | orbital <orbital@holgerines.de> | 2023-04-02 22:05:13 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2023-04-02 22:05:13 +0100 |
commit | cde8de034524d00aba4ff4142e658baff511e12d (patch) | |
tree | 3546be90832d785283ee31a4001205b3a0cc892c | |
parent | 065088d5549e7711668321cc5a77c9a9b684b142 (diff) | |
download | vim-git-cde8de034524d00aba4ff4142e658baff511e12d.tar.gz |
patch 9.0.1439: start Insert mode when accessing a hidden prompt bufferv9.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)
-rw-r--r-- | src/autocmd.c | 5 | ||||
-rw-r--r-- | src/proto/window.pro | 1 | ||||
-rw-r--r-- | src/testdir/test_prompt_buffer.vim | 38 | ||||
-rw-r--r-- | src/version.c | 2 | ||||
-rw-r--r-- | src/window.c | 2 |
5 files changed, 46 insertions, 2 deletions
diff --git a/src/autocmd.c b/src/autocmd.c index fe2b6cbb1..e5f512503 100644 --- a/src/autocmd.c +++ b/src/autocmd.c @@ -1657,7 +1657,10 @@ aucmd_restbuf( } } 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); diff --git a/src/proto/window.pro b/src/proto/window.pro index 6522466be..d1108af50 100644 --- a/src/proto/window.pro +++ b/src/proto/window.pro @@ -13,6 +13,7 @@ int win_count(void); 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); diff --git a/src/testdir/test_prompt_buffer.vim b/src/testdir/test_prompt_buffer.vim index 9998cc5da..28e0d765f 100644 --- a/src/testdir/test_prompt_buffer.vim +++ b/src/testdir/test_prompt_buffer.vim @@ -252,4 +252,42 @@ func Test_prompt_while_writing_to_hidden_buffer() 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 diff --git a/src/version.c b/src/version.c index 47ecd534e..5cace2e38 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 */ /**/ + 1439, +/**/ 1438, /**/ 1437, diff --git a/src/window.c b/src/window.c index a967f9217..3405285c0 100644 --- a/src/window.c +++ b/src/window.c @@ -2292,7 +2292,7 @@ win_equal_rec( } #ifdef FEAT_JOB_CHANNEL - static void + void leaving_window(win_T *win) { // Only matters for a prompt window. |