• R/O
  • SSH

vim: Commit

Mirror of the Vim source from https://github.com/vim/vim


Commit MetaInfo

Revision58a6e51b437be780bbccd9ba87a09c9396c97095 (tree)
Time2024-01-18 05:30:03
AuthorChristian Brabandt <cb@256b...>
CommiterChristian Brabandt

Log Message

patch 9.1.0040: issue with prompt buffer and hidden buffer

Commit: https://github.com/vim/vim/commit/f267847017976ab85117bdf75b45e769836f8d69
Author: zeertzjq <zeertzjq@outlook.com>
Date: Wed Jan 17 21:22:59 2024 +0100

patch 9.1.0040: issue with prompt buffer and hidden buffer
Problem: Modifying a hidden buffer still interferes with prompt buffer
mode changes.
Solution: Save and restore b_prompt_insert.
(zeertzjq)
closes: #13875
Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Modifying hidden buffer still interferes with prompt buffer mode changes

Change Summary

Incremental Difference

diff -r bdf6bc7efe3c -r 58a6e51b437b src/autocmd.c
--- a/src/autocmd.c Wed Jan 17 21:15:04 2024 +0100
+++ b/src/autocmd.c Wed Jan 17 21:30:03 2024 +0100
@@ -1565,9 +1565,12 @@
15651565 }
15661566
15671567 aco->save_curwin_id = curwin->w_id;
1568- aco->save_curbuf = curbuf;
15691568 aco->save_prevwin_id = prevwin == NULL ? 0 : prevwin->w_id;
15701569 aco->save_State = State;
1570+#ifdef FEAT_JOB_CHANNEL
1571+ if (bt_prompt(curbuf))
1572+ aco->save_prompt_insert = curbuf->b_prompt_insert;
1573+#endif
15711574
15721575 if (win != NULL)
15731576 {
@@ -1692,6 +1695,8 @@
16921695 #ifdef FEAT_JOB_CHANNEL
16931696 // May need to restore insert mode for a prompt buffer.
16941697 entering_window(curwin);
1698+ if (bt_prompt(curbuf))
1699+ curbuf->b_prompt_insert = aco->save_prompt_insert;
16951700 #endif
16961701 prevwin = win_find_by_id(aco->save_prevwin_id);
16971702 #ifdef FEAT_EVAL
diff -r bdf6bc7efe3c -r 58a6e51b437b src/structs.h
--- a/src/structs.h Wed Jan 17 21:15:04 2024 +0100
+++ b/src/structs.h Wed Jan 17 21:30:03 2024 +0100
@@ -4358,7 +4358,6 @@
43584358 */
43594359 typedef struct
43604360 {
4361- buf_T *save_curbuf; // saved curbuf
43624361 int use_aucmd_win_idx; // index in aucmd_win[] if >= 0
43634362 int save_curwin_id; // ID of saved curwin
43644363 int new_curwin_id; // ID of new curwin
@@ -4367,6 +4366,9 @@
43674366 char_u *globaldir; // saved value of globaldir
43684367 int save_VIsual_active; // saved VIsual_active
43694368 int save_State; // saved State
4369+#ifdef FEAT_JOB_CHANNEL
4370+ int save_prompt_insert; // saved b_prompt_insert
4371+#endif
43704372 } aco_save_T;
43714373
43724374 /*
diff -r bdf6bc7efe3c -r 58a6e51b437b src/testdir/test_prompt_buffer.vim
--- a/src/testdir/test_prompt_buffer.vim Wed Jan 17 21:15:04 2024 +0100
+++ b/src/testdir/test_prompt_buffer.vim Wed Jan 17 21:30:03 2024 +0100
@@ -297,9 +297,10 @@
297297 call StopVimInTerminal(buf)
298298 endfunc
299299
300-" Modifying a hidden buffer while closing a prompt buffer should not prevent
301-" stopping of Insert mode.
302-func Test_prompt_close_modify_hidden()
300+" Modifying a hidden buffer while leaving a prompt buffer should not prevent
301+" stopping of Insert mode, and returning to the prompt buffer later should
302+" restore Insert mode.
303+func Test_prompt_leave_modify_hidden()
303304 call CanTestPromptBuffer()
304305
305306 let script =<< trim END
@@ -309,22 +310,34 @@
309310 new prompt
310311 set buftype=prompt
311312
313+ inoremap <buffer> w <Cmd>wincmd w<CR>
312314 inoremap <buffer> q <Cmd>bwipe!<CR>
313- autocmd BufWinLeave prompt call setbufline('hidden', 1, 'Test')
315+ autocmd BufLeave prompt call appendbufline('hidden', '$', 'Leave')
316+ autocmd BufEnter prompt call appendbufline('hidden', '$', 'Enter')
317+ autocmd BufWinLeave prompt call appendbufline('hidden', '$', 'Close')
314318 END
315- call writefile(script, 'XpromptCloseModifyHidden', 'D')
319+ call writefile(script, 'XpromptLeaveModifyHidden', 'D')
316320
317- let buf = RunVimInTerminal('-S XpromptCloseModifyHidden', {'rows': 10})
321+ let buf = RunVimInTerminal('-S XpromptLeaveModifyHidden', {'rows': 10})
318322 call TermWait(buf)
319323
320324 call term_sendkeys(buf, "a")
321325 call WaitForAssert({-> assert_match('-- INSERT --', term_getline(buf, 10))})
322326
327+ call term_sendkeys(buf, "w")
328+ call WaitForAssert({-> assert_notmatch('-- INSERT --', term_getline(buf, 10))})
329+
330+ call term_sendkeys(buf, "\<C-W>w")
331+ call WaitForAssert({-> assert_match('-- INSERT --', term_getline(buf, 10))})
332+
323333 call term_sendkeys(buf, "q")
324334 call WaitForAssert({-> assert_notmatch('-- INSERT --', term_getline(buf, 10))})
325335
326336 call term_sendkeys(buf, ":bwipe!\<CR>")
327- call WaitForAssert({-> assert_equal('Test', term_getline(buf, 1))})
337+ call WaitForAssert({-> assert_equal('Leave', term_getline(buf, 2))})
338+ call WaitForAssert({-> assert_equal('Enter', term_getline(buf, 3))})
339+ call WaitForAssert({-> assert_equal('Leave', term_getline(buf, 4))})
340+ call WaitForAssert({-> assert_equal('Close', term_getline(buf, 5))})
328341
329342 call StopVimInTerminal(buf)
330343 endfunc
diff -r bdf6bc7efe3c -r 58a6e51b437b src/version.c
--- a/src/version.c Wed Jan 17 21:15:04 2024 +0100
+++ b/src/version.c Wed Jan 17 21:30:03 2024 +0100
@@ -705,6 +705,8 @@
705705 static int included_patches[] =
706706 { /* Add new patch number below this line */
707707 /**/
708+ 40,
709+/**/
708710 39,
709711 /**/
710712 38,
Show on old repository browser