diff 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
line wrap: on
line diff
--- a/src/testdir/test_terminal.vim
+++ b/src/testdir/test_terminal.vim
@@ -352,9 +352,7 @@ func Test_terminal_curwin()
   call delete('Xtext')
 endfunc
 
-func Test_finish_open_close()
-  call assert_equal(1, winnr('$'))
-
+func s:get_sleep_cmd()
   if s:python != ''
     let cmd = s:python . " test_short_sleep.py"
     let waittime = 500
@@ -367,12 +365,18 @@ func Test_finish_open_close()
       let cmd = 'sleep 1'
     endif
   endif
+  return [cmd, waittime]
+endfunc
+
+func Test_terminal_finish_open_close()
+  call assert_equal(1, winnr('$'))
+
+  let [cmd, waittime] = s:get_sleep_cmd()
 
   exe 'terminal ++close ' . cmd
   call assert_equal(2, winnr('$'))
   wincmd p
   call WaitFor("winnr('$') == 1", waittime)
-  call assert_equal(1, winnr('$'))
 
   call term_start(cmd, {'term_finish': 'close'})
   call assert_equal(2, winnr('$'))
@@ -743,3 +747,29 @@ func Test_terminal_composing_unicode()
   unlet g:job
   let &encoding = save_enc
 endfunc
+
+func Test_terminal_aucmd_on_close()
+  fun Nop()
+    let s:called = 1
+  endfun
+
+  aug repro
+      au!
+      au BufWinLeave * call Nop()
+  aug END
+
+  let [cmd, waittime] = s:get_sleep_cmd()
+
+  call assert_equal(1, winnr('$'))
+  new
+  call setline(1, ['one', 'two'])
+  exe 'term ++close ' . cmd
+  wincmd p
+  call WaitFor("winnr('$') == 2", waittime)
+  call assert_equal(1, s:called)
+  bwipe!
+
+  unlet s:called
+  au! repro
+  delfunc Nop
+endfunc