Skip to content

Commit d8558fd

Browse files
zeertzjqchrisbra
authored andcommitted
patch 9.1.2066: :wqall! doesn't close a terminal like :qall! does
Problem: :wqall! doesn't close a terminal buffer like :qall! does (after 8.0.1525). Solution: Check eap->forceit (zeertzjq). Ref: vim/vim#2654 (comment) related: #2654 related: neovim/neovim#14061 closes: #19129 Signed-off-by: zeertzjq <[email protected]> Signed-off-by: Christian Brabandt <[email protected]>
1 parent 7d632a0 commit d8558fd

5 files changed

Lines changed: 30 additions & 6 deletions

File tree

src/buffer.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ static int append_arg_number(win_T *wp, char_u *buf, size_t buflen, int add_file
4949
static void free_buffer(buf_T *);
5050
static void free_buffer_stuff(buf_T *buf, int free_options);
5151
static int bt_nofileread(buf_T *buf);
52-
static void no_write_message_buf(buf_T *buf);
5352
static int do_buffer_ext(int action, int start, int dir, int count, int flags);
5453

5554
#ifdef UNIX
@@ -2079,8 +2078,8 @@ do_autochdir(void)
20792078
}
20802079
#endif
20812080

2082-
static void
2083-
no_write_message_buf(buf_T *buf UNUSED)
2081+
void
2082+
no_write_message_buf(buf_T *buf)
20842083
{
20852084
#ifdef FEAT_TERMINAL
20862085
if (term_job_running(buf->b_term))

src/ex_cmds.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2509,9 +2509,9 @@ do_wqall(exarg_T *eap)
25092509
FOR_ALL_BUFFERS(buf)
25102510
{
25112511
#ifdef FEAT_TERMINAL
2512-
if (exiting && term_job_running(buf->b_term))
2512+
if (exiting && !eap->forceit && term_job_running(buf->b_term))
25132513
{
2514-
no_write_message_nobang(buf);
2514+
no_write_message_buf(buf);
25152515
++error;
25162516
}
25172517
else

src/proto/buffer.pro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ int do_buffer(int action, int start, int dir, int count, int forceit);
1515
char *do_bufdel(int command, char_u *arg, int addr_count, int start_bnr, int end_bnr, int forceit);
1616
void set_curbuf(buf_T *buf, int action);
1717
void do_autochdir(void);
18+
void no_write_message_buf(buf_T *buf);
1819
void no_write_message(void);
1920
void no_write_message_nobang(buf_T *buf);
2021
int curbuf_reusable(void);

src/testdir/test_terminal.vim

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1368,7 +1368,7 @@ func Test_terminal_qall_kill_func()
13681368
endfunc
13691369

13701370
" Run Vim, start a terminal in that Vim without the kill argument,
1371-
" check that :qall does not exit, :qall! does.
1371+
" check that :qall does not exit.
13721372
func Test_terminal_qall_exit()
13731373
let after =<< trim [CODE]
13741374
term
@@ -1390,6 +1390,28 @@ func Test_terminal_qall_exit()
13901390
call delete("Xdone")
13911391
endfunc
13921392

1393+
" :qall! and :wqall! should exit when there is a terminal buffer.
1394+
func Test_terminal_qall_wqall_bang_exit()
1395+
for cmd in ['qall!', 'wqall!']
1396+
let after =<< trim eval [CODE]
1397+
term
1398+
let buf = bufnr("%")
1399+
while term_getline(buf, 1) =~ "^\\s*$"
1400+
sleep 10m
1401+
endwhile
1402+
set nomore
1403+
au VimLeavePre * call writefile(["done"], "Xdone")
1404+
{cmd}
1405+
[CODE]
1406+
1407+
if !RunVim([], after, '')
1408+
continue
1409+
endif
1410+
call assert_equal("done", readfile("Xdone")[0])
1411+
call delete("Xdone")
1412+
endfor
1413+
endfunc
1414+
13931415
" Run Vim in a terminal, then start a terminal in that Vim without a kill
13941416
" argument, check that :confirm qall works.
13951417
func Test_terminal_qall_prompt()

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -734,6 +734,8 @@ static char *(features[]) =
734734

735735
static int included_patches[] =
736736
{ /* Add new patch number below this line */
737+
/**/
738+
2066,
737739
/**/
738740
2065,
739741
/**/

0 commit comments

Comments
 (0)