patch 8.0.0896: cannot close a terminal window when the job ends
Problem: Cannot automaticlaly close a terminal window when the job ends.
Solution: Add the ++close argument to :term. Add the term_finish option to
term_start(). (Yasuhiro Matsumoto, closes #1950) Also add
++open.
diff --git a/src/testdir/test_terminal.vim b/src/testdir/test_terminal.vim
index cd884e1..89a784b 100644
--- a/src/testdir/test_terminal.vim
+++ b/src/testdir/test_terminal.vim
@@ -264,3 +264,43 @@
bwipe!
call assert_equal([6, 20], size)
endfunc
+
+func Test_finish_close()
+ call assert_equal(1, winnr('$'))
+
+ " TODO: use something that takes much less than a whole second
+ if has('win32')
+ let cmd = $windir . '\system32\timeout.exe 1'
+ else
+ let cmd = 'sleep 1'
+ endif
+ exe 'terminal ++close ' . cmd
+ let buf = bufnr('')
+ call assert_equal(2, winnr('$'))
+
+ wincmd p
+ sleep 1200 msec
+ call assert_equal(1, winnr('$'))
+
+ call term_start(cmd, {'term_finish': 'close'})
+ call assert_equal(2, winnr('$'))
+ let buf = bufnr('')
+ wincmd p
+ sleep 1200 msec
+ call assert_equal(1, winnr('$'))
+
+ exe 'terminal ++open ' . cmd
+ let buf = bufnr('')
+ close
+ sleep 1200 msec
+ call assert_equal(2, winnr('$'))
+ bwipe
+
+ call term_start(cmd, {'term_finish': 'open'})
+ let buf = bufnr('')
+ close
+ sleep 1200 msec
+ call assert_equal(2, winnr('$'))
+
+ bwipe
+endfunc