changeset 22987:1456b8e4d489 v8.2.2040

patch 8.2.2040: terminal buffer disappears even when 'bufhidden' is "hide" Commit: https://github.com/vim/vim/commit/c9f8b849b6de9661e543d0d1431e233725dd956f Author: Bram Moolenaar <Bram@vim.org> Date: Tue Nov 24 19:36:16 2020 +0100 patch 8.2.2040: terminal buffer disappears even when 'bufhidden' is "hide" Problem: Terminal buffer disappears even when 'bufhidden' is "hide". (Sergey Vlasov) Solution: Check 'bufhiddden' when a terminal buffer becomes hidden. (closes #7358)
author Bram Moolenaar <Bram@vim.org>
date Tue, 24 Nov 2020 19:45:03 +0100
parents 464aed98daf3
children 6a48b29a5fb5
files src/buffer.c src/testdir/test_terminal.vim src/version.c
diffstat 3 files changed, 27 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -552,6 +552,11 @@ close_buffer(
 		unload_buf = FALSE;
 	    }
 	}
+	else if (buf->b_p_bh[0] == 'h' && !del_buf)
+	{
+	    // Hide a terminal buffer.
+	    unload_buf = FALSE;
+	}
 	else
 	{
 	    // A terminal buffer is wiped out if the job has finished.
--- a/src/testdir/test_terminal.vim
+++ b/src/testdir/test_terminal.vim
@@ -123,7 +123,7 @@ func Test_terminal_split_quit()
   unlet g:job
 endfunc
 
-func Test_terminal_hide_buffer()
+func Test_terminal_hide_buffer_job_running()
   let buf = Run_shell_in_terminal({})
   setlocal bufhidden=hide
   quit
@@ -140,6 +140,25 @@ func Test_terminal_hide_buffer()
   unlet g:job
 endfunc
 
+func Test_terminal_hide_buffer_job_finished()
+  term echo hello
+  let buf = bufnr()
+  setlocal bufhidden=hide
+  call WaitForAssert({-> assert_equal('finished', term_getstatus(buf))})
+  call assert_true(bufloaded(buf))
+  call assert_true(buflisted(buf))
+  edit Xasdfasdf
+  call assert_true(bufloaded(buf))
+  call assert_true(buflisted(buf))
+  exe buf .. 'buf'
+  call assert_equal(buf, bufnr())
+  setlocal bufhidden=
+  edit Xasdfasdf
+  call assert_false(bufloaded(buf))
+  call assert_false(buflisted(buf))
+  bwipe Xasdfasdf
+endfunc
+
 func s:Nasty_exit_cb(job, st)
   exe g:buf . 'bwipe!'
   let g:buf = 0
--- a/src/version.c
+++ b/src/version.c
@@ -751,6 +751,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    2040,
+/**/
     2039,
 /**/
     2038,