Mercurial > vim
comparison src/testdir/test_terminal.vim @ 13438:33eea5ce5415 v8.0.1593
patch 8.0.1593: :qall never exits with an active terminal window
commit https://github.com/vim/vim/commit/25cdd9c33b21ddbd31321c075873bb225450d2d2
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Mar 10 20:28:12 2018 +0100
patch 8.0.1593: :qall never exits with an active terminal window
Problem: :qall never exits with an active terminal window.
Solution: Add a way to kill a job in a terminal window.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sat, 10 Mar 2018 20:30:04 +0100 |
parents | fa198b71bab2 |
children | 22439cdda382 |
comparison
equal
deleted
inserted
replaced
13437:02b3f719eacb | 13438:33eea5ce5415 |
---|---|
3 if !has('terminal') | 3 if !has('terminal') |
4 finish | 4 finish |
5 endif | 5 endif |
6 | 6 |
7 source shared.vim | 7 source shared.vim |
8 source screendump.vim | |
8 | 9 |
9 let s:python = PythonProg() | 10 let s:python = PythonProg() |
10 | 11 |
11 " Open a terminal with a shell, assign the job to g:job and return the buffer | 12 " Open a terminal with a shell, assign the job to g:job and return the buffer |
12 " number. | 13 " number. |
837 | 838 |
838 exe buf . 'bwipe' | 839 exe buf . 'bwipe' |
839 call delete('Xescape') | 840 call delete('Xescape') |
840 unlet g:job | 841 unlet g:job |
841 endfunc | 842 endfunc |
843 | |
844 " Run Vim in a terminal, then start a terminal in that Vim with a kill | |
845 " argument, check that :qall works. | |
846 func Test_terminal_qall_kill_arg() | |
847 if !CanRunVimInTerminal() | |
848 return | |
849 endif | |
850 let buf = RunVimInTerminal('', {}) | |
851 | |
852 " Open a terminal window and wait for the prompt to appear | |
853 call term_sendkeys(buf, ":term ++kill=kill\<CR>") | |
854 call WaitFor({-> term_getline(buf, 10) =~ '\[running]'}) | |
855 call WaitFor({-> term_getline(buf, 1) !~ '^\s*$'}) | |
856 | |
857 " make Vim exit, it will kill the shell | |
858 call term_sendkeys(buf, "\<C-W>:qall\<CR>") | |
859 call WaitFor({-> term_getstatus(buf) == "finished"}) | |
860 | |
861 " close the terminal window where Vim was running | |
862 quit | |
863 endfunc | |
864 | |
865 " Run Vim in a terminal, then start a terminal in that Vim with a kill | |
866 " argument, check that :qall works. | |
867 func Test_terminal_qall_kill_func() | |
868 if !CanRunVimInTerminal() | |
869 return | |
870 endif | |
871 let buf = RunVimInTerminal('', {}) | |
872 | |
873 " Open a terminal window and wait for the prompt to appear | |
874 call term_sendkeys(buf, ":term\<CR>") | |
875 call WaitFor({-> term_getline(buf, 10) =~ '\[running]'}) | |
876 call WaitFor({-> term_getline(buf, 1) !~ '^\s*$'}) | |
877 | |
878 " set kill using term_setkill() | |
879 call term_sendkeys(buf, "\<C-W>:call term_setkill(bufnr('%'), 'kill')\<CR>") | |
880 | |
881 " make Vim exit, it will kill the shell | |
882 call term_sendkeys(buf, "\<C-W>:qall\<CR>") | |
883 call WaitFor({-> term_getstatus(buf) == "finished"}) | |
884 | |
885 " close the terminal window where Vim was running | |
886 quit | |
887 endfunc |