patch 8.1.2195: Vim does not exit when the terminal window is last window
Problem: Vim does not exit when closing a terminal window and it is the
last window.
Solution: Exit Vim if the closed terminal window is the last one.
(closes #4539)
diff --git a/src/testdir/test_terminal.vim b/src/testdir/test_terminal.vim
index c4d3e52..f506a39 100644
--- a/src/testdir/test_terminal.vim
+++ b/src/testdir/test_terminal.vim
@@ -1051,6 +1051,32 @@
quit
endfunc
+" Run Vim in a terminal, then start a terminal window with a shell and check
+" that Vim exits if it is closed.
+func Test_terminal_exit()
+ CheckRunVimInTerminal
+
+ let lines =<< trim END
+ let winid = win_getid()
+ help
+ term
+ let termid = win_getid()
+ call win_gotoid(winid)
+ close
+ call win_gotoid(termid)
+ END
+ call writefile(lines, 'XtermExit')
+ let buf = RunVimInTerminal('-S XtermExit', #{rows: 10})
+ let job = term_getjob(buf)
+ call WaitForAssert({-> assert_equal("run", job_status(job))})
+
+ " quit the shell, it will make Vim exit
+ call term_sendkeys(buf, "exit\<CR>")
+ call WaitForAssert({-> assert_equal("dead", job_status(job))})
+
+ call delete('XtermExit')
+endfunc
+
func Test_terminal_open_autocmd()
augroup repro
au!