Mercurial > vim
comparison src/testdir/test_terminal.vim @ 11917:00836eb177cb v8.0.0838
patch 8.0.0838: buffer hangs around whem terminal window is closed
commit https://github.com/vim/vim/commit/94053a51255121713f51c122eb0dbb46c120e6d4
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Aug 1 21:44:33 2017 +0200
patch 8.0.0838: buffer hangs around whem terminal window is closed
Problem: Buffer hangs around whem terminal window is closed.
Solution: When the job has ended wipe out a terminal buffer when the window
is closed.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Tue, 01 Aug 2017 21:45:04 +0200 |
parents | 22658e33203f |
children | c9da7b42fdf5 |
comparison
equal
deleted
inserted
replaced
11916:de8aede995aa | 11917:00836eb177cb |
---|---|
4 finish | 4 finish |
5 endif | 5 endif |
6 | 6 |
7 source shared.vim | 7 source shared.vim |
8 | 8 |
9 " Open a terminal with a shell, assign the job to g:job and return the buffer | |
10 " number. | |
9 func Run_shell_in_terminal() | 11 func Run_shell_in_terminal() |
10 let buf = term_start(&shell) | 12 let buf = term_start(&shell) |
11 | 13 |
12 let termlist = term_list() | 14 let termlist = term_list() |
13 call assert_equal(1, len(termlist)) | 15 call assert_equal(1, len(termlist)) |
14 call assert_equal(buf, termlist[0]) | 16 call assert_equal(buf, termlist[0]) |
15 | 17 |
16 let g:job = term_getjob(buf) | 18 let g:job = term_getjob(buf) |
17 call assert_equal(v:t_job, type(g:job)) | 19 call assert_equal(v:t_job, type(g:job)) |
18 | 20 |
19 call term_sendkeys(buf, "exit\r") | 21 return buf |
22 endfunc | |
23 | |
24 " Stops the shell started by Run_shell_in_terminal(). | |
25 func Stop_shell_in_terminal(buf) | |
26 call term_sendkeys(a:buf, "exit\r") | |
20 call WaitFor('job_status(g:job) == "dead"') | 27 call WaitFor('job_status(g:job) == "dead"') |
21 call assert_equal('dead', job_status(g:job)) | 28 call assert_equal('dead', job_status(g:job)) |
22 | |
23 return buf | |
24 endfunc | 29 endfunc |
25 | 30 |
26 func Test_terminal_basic() | 31 func Test_terminal_basic() |
27 let buf = Run_shell_in_terminal() | 32 let buf = Run_shell_in_terminal() |
33 call Stop_shell_in_terminal(buf) | |
34 call term_wait(buf) | |
28 | 35 |
29 exe buf . 'bwipe' | 36 " closing window wipes out the terminal buffer a with finished job |
37 close | |
38 call assert_equal("", bufname(buf)) | |
39 | |
30 unlet g:job | 40 unlet g:job |
31 endfunc | 41 endfunc |
32 | 42 |
33 func Test_terminal_make_change() | 43 func Test_terminal_make_change() |
34 let buf = Run_shell_in_terminal() | 44 let buf = Run_shell_in_terminal() |
45 call Stop_shell_in_terminal(buf) | |
35 call term_wait(buf) | 46 call term_wait(buf) |
36 | 47 |
37 setlocal modifiable | 48 setlocal modifiable |
38 exe "normal Axxx\<Esc>" | 49 exe "normal Axxx\<Esc>" |
39 call assert_fails(buf . 'bwipe', 'E517') | 50 call assert_fails(buf . 'bwipe', 'E517') |
40 undo | 51 undo |
41 | 52 |
42 exe buf . 'bwipe' | 53 exe buf . 'bwipe' |
54 unlet g:job | |
55 endfunc | |
56 | |
57 func Test_terminal_wipe_buffer() | |
58 let buf = Run_shell_in_terminal() | |
59 exe buf . 'bwipe' | |
60 call WaitFor('job_status(g:job) == "dead"') | |
61 call assert_equal('dead', job_status(g:job)) | |
62 call assert_equal("", bufname(buf)) | |
63 | |
64 unlet g:job | |
65 endfunc | |
66 | |
67 func Test_terminal_hide_buffer() | |
68 let buf = Run_shell_in_terminal() | |
69 quit | |
70 for nr in range(1, winnr('$')) | |
71 call assert_notequal(winbufnr(nr), buf) | |
72 endfor | |
73 call assert_true(bufloaded(buf)) | |
74 call assert_true(buflisted(buf)) | |
75 | |
76 exe 'split ' . buf . 'buf' | |
77 call Stop_shell_in_terminal(buf) | |
78 exe buf . 'bwipe' | |
79 | |
43 unlet g:job | 80 unlet g:job |
44 endfunc | 81 endfunc |
45 | 82 |
46 func Check_123(buf) | 83 func Check_123(buf) |
47 let l = term_scrape(a:buf, 1) | 84 let l = term_scrape(a:buf, 1) |