comparison src/testdir/test_terminal.vim @ 12903:411a30bd7e8a v8.0.1328

patch 8.0.1328: trouble when using ":term ++close" with autocmd commit https://github.com/vim/vim/commit/ff5467965e3871d3dc0288416fcc6b1e2ba4f822 Author: Bram Moolenaar <Bram@vim.org> Date: Tue Nov 21 14:47:57 2017 +0100 patch 8.0.1328: trouble when using ":term ++close" with autocmd Problem: Trouble when using ":term ++close" with autocmd. (Gabriel Barta) Solution: Use aucmd_prepbuf() and aucmd_restbuf() instead of setting curbuf. (closes #2339)
author Christian Brabandt <cb@256bit.org>
date Tue, 21 Nov 2017 15:00:06 +0100
parents c1347c968d31
children 32531a3eab1f
comparison
equal deleted inserted replaced
12902:9e528acde057 12903:411a30bd7e8a
350 split dummy 350 split dummy
351 bwipe! 351 bwipe!
352 call delete('Xtext') 352 call delete('Xtext')
353 endfunc 353 endfunc
354 354
355 func Test_finish_open_close() 355 func s:get_sleep_cmd()
356 call assert_equal(1, winnr('$'))
357
358 if s:python != '' 356 if s:python != ''
359 let cmd = s:python . " test_short_sleep.py" 357 let cmd = s:python . " test_short_sleep.py"
360 let waittime = 500 358 let waittime = 500
361 else 359 else
362 echo 'This will take five seconds...' 360 echo 'This will take five seconds...'
365 let cmd = $windir . '\system32\timeout.exe 1' 363 let cmd = $windir . '\system32\timeout.exe 1'
366 else 364 else
367 let cmd = 'sleep 1' 365 let cmd = 'sleep 1'
368 endif 366 endif
369 endif 367 endif
368 return [cmd, waittime]
369 endfunc
370
371 func Test_terminal_finish_open_close()
372 call assert_equal(1, winnr('$'))
373
374 let [cmd, waittime] = s:get_sleep_cmd()
370 375
371 exe 'terminal ++close ' . cmd 376 exe 'terminal ++close ' . cmd
372 call assert_equal(2, winnr('$')) 377 call assert_equal(2, winnr('$'))
373 wincmd p 378 wincmd p
374 call WaitFor("winnr('$') == 1", waittime) 379 call WaitFor("winnr('$') == 1", waittime)
375 call assert_equal(1, winnr('$'))
376 380
377 call term_start(cmd, {'term_finish': 'close'}) 381 call term_start(cmd, {'term_finish': 'close'})
378 call assert_equal(2, winnr('$')) 382 call assert_equal(2, winnr('$'))
379 wincmd p 383 wincmd p
380 call WaitFor("winnr('$') == 1", waittime) 384 call WaitFor("winnr('$') == 1", waittime)
741 call assert_equal('dead', job_status(g:job)) 745 call assert_equal('dead', job_status(g:job))
742 bwipe! 746 bwipe!
743 unlet g:job 747 unlet g:job
744 let &encoding = save_enc 748 let &encoding = save_enc
745 endfunc 749 endfunc
750
751 func Test_terminal_aucmd_on_close()
752 fun Nop()
753 let s:called = 1
754 endfun
755
756 aug repro
757 au!
758 au BufWinLeave * call Nop()
759 aug END
760
761 let [cmd, waittime] = s:get_sleep_cmd()
762
763 call assert_equal(1, winnr('$'))
764 new
765 call setline(1, ['one', 'two'])
766 exe 'term ++close ' . cmd
767 wincmd p
768 call WaitFor("winnr('$') == 2", waittime)
769 call assert_equal(1, s:called)
770 bwipe!
771
772 unlet s:called
773 au! repro
774 delfunc Nop
775 endfunc