diff src/testdir/test_autocmd.vim @ 19489:31ac050a29a7 v8.2.0302

patch 8.2.0302: setting 'term' may cause error in TermChanged autocommand Commit: https://github.com/vim/vim/commit/0c81d1b11278b2d962aa6fbb4aa974dab97be59d Author: Bram Moolenaar <Bram@vim.org> Date: Sat Feb 22 22:45:55 2020 +0100 patch 8.2.0302: setting 'term' may cause error in TermChanged autocommand Problem: Setting 'term' may cause error in TermChanged autocommand. Solution: Use aucmd_prepbuf() to switch to the buffer where the autocommand is to be executed. (closes #5682)
author Bram Moolenaar <Bram@vim.org>
date Sat, 22 Feb 2020 23:00:05 +0100
parents 8f8a5a15d00a
children 7803c6e82a87
line wrap: on
line diff
--- a/src/testdir/test_autocmd.vim
+++ b/src/testdir/test_autocmd.vim
@@ -2382,4 +2382,24 @@ func Test_FileChangedRO_winclose()
   augroup! FileChangedROTest
 endfunc
 
+func LogACmd()
+  call add(g:logged, line('$'))
+endfunc
+
+func Test_TermChanged()
+  enew!
+  tabnew
+  call setline(1, ['a', 'b', 'c', 'd'])
+  $
+  au TermChanged * call LogACmd()
+  let g:logged = []
+  let term_save = &term
+  set term=xterm
+  call assert_equal([1, 4], g:logged)
+
+  au! TermChanged
+  let &term = term_save
+  bwipe!
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab