diff src/testdir/test_terminal.vim @ 18402:527b7084c556 v8.1.2195

patch 8.1.2195: Vim does not exit when the terminal window is last window Commit: https://github.com/vim/vim/commit/4d14bac8e7441368977e81266166f728105a60d4 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Oct 20 21:15:15 2019 +0200 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)
author Bram Moolenaar <Bram@vim.org>
date Sun, 20 Oct 2019 21:30:03 +0200
parents 0e9d3a77c624
children 507348b211b4
line wrap: on
line diff
--- a/src/testdir/test_terminal.vim
+++ b/src/testdir/test_terminal.vim
@@ -1051,6 +1051,32 @@ func Test_terminal_qall_prompt()
   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!