]> granicus.if.org Git - vim/commitdiff
patch 8.0.1119: quitting a split terminal window kills the job v8.0.1119
authorBram Moolenaar <Bram@vim.org>
Sun, 17 Sep 2017 17:08:02 +0000 (19:08 +0200)
committerBram Moolenaar <Bram@vim.org>
Sun, 17 Sep 2017 17:08:02 +0000 (19:08 +0200)
Problem:    Quitting a split terminal window kills the job. (Yasuhiro
            Matsumoto)
Solution:   Only stop terminal job if it is the last window.

src/buffer.c
src/testdir/test_terminal.vim
src/version.c

index 110dada7a642a0b01df28e5e5dbe9a62d18d8647..7040bb1005721ebdf260b1c89ece1b9613cf3985 100644 (file)
@@ -466,8 +466,27 @@ close_buffer(
     int                del_buf = (action == DOBUF_DEL || action == DOBUF_WIPE);
     int                wipe_buf = (action == DOBUF_WIPE);
 
+    /*
+     * Force unloading or deleting when 'bufhidden' says so.
+     * The caller must take care of NOT deleting/freeing when 'bufhidden' is
+     * "hide" (otherwise we could never free or delete a buffer).
+     */
+    if (buf->b_p_bh[0] == 'd')         /* 'bufhidden' == "delete" */
+    {
+       del_buf = TRUE;
+       unload_buf = TRUE;
+    }
+    else if (buf->b_p_bh[0] == 'w')    /* 'bufhidden' == "wipe" */
+    {
+       del_buf = TRUE;
+       unload_buf = TRUE;
+       wipe_buf = TRUE;
+    }
+    else if (buf->b_p_bh[0] == 'u')    /* 'bufhidden' == "unload" */
+       unload_buf = TRUE;
+
 #ifdef FEAT_TERMINAL
-    if (bt_terminal(buf))
+    if (bt_terminal(buf) && (buf->b_nwindows == 1 || del_buf))
     {
        if (term_job_running(buf->b_term))
        {
@@ -489,26 +508,7 @@ close_buffer(
            wipe_buf = TRUE;
        }
     }
-    else
 #endif
-    /*
-     * Force unloading or deleting when 'bufhidden' says so.
-     * The caller must take care of NOT deleting/freeing when 'bufhidden' is
-     * "hide" (otherwise we could never free or delete a buffer).
-     */
-    if (buf->b_p_bh[0] == 'd')         /* 'bufhidden' == "delete" */
-    {
-       del_buf = TRUE;
-       unload_buf = TRUE;
-    }
-    else if (buf->b_p_bh[0] == 'w')    /* 'bufhidden' == "wipe" */
-    {
-       del_buf = TRUE;
-       unload_buf = TRUE;
-       wipe_buf = TRUE;
-    }
-    else if (buf->b_p_bh[0] == 'u')    /* 'bufhidden' == "unload" */
-       unload_buf = TRUE;
 
 #ifdef FEAT_AUTOCMD
     /* Disallow deleting the buffer when it is locked (already being closed or
index a4031cedf178ffab8999e6da4674aaa41c70dae5..17167e89ffb033a9bda178d2a3d305560b78a0c9 100644 (file)
@@ -82,6 +82,23 @@ func Test_terminal_wipe_buffer()
   unlet g:job
 endfunc
 
+func Test_terminal_split_quit()
+  let buf = Run_shell_in_terminal({})
+  call term_wait(buf)
+  split
+  quit!
+  call term_wait(buf)
+  sleep 50m
+  call assert_equal('run', job_status(g:job))
+
+  quit!
+  call WaitFor('job_status(g:job) == "dead"')
+  call assert_equal('dead', job_status(g:job))
+
+  exe buf . 'bwipe'
+  unlet g:job
+endfunc
+
 func Test_terminal_hide_buffer()
   let buf = Run_shell_in_terminal({})
   setlocal bufhidden=hide
index 21ecc934455483f3144fac3095ed367843677c0d..893de43ac6651032b73dacecb2ef786563338075 100644 (file)
@@ -761,6 +761,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1119,
 /**/
     1118,
 /**/