aboutsummaryrefslogtreecommitdiff
path: root/test/old/testdir/test_autocmd.vim
diff options
context:
space:
mode:
Diffstat (limited to 'test/old/testdir/test_autocmd.vim')
-rw-r--r--test/old/testdir/test_autocmd.vim64
1 files changed, 61 insertions, 3 deletions
diff --git a/test/old/testdir/test_autocmd.vim b/test/old/testdir/test_autocmd.vim
index cdcd68f3d6..9d06ebb2be 100644
--- a/test/old/testdir/test_autocmd.vim
+++ b/test/old/testdir/test_autocmd.vim
@@ -15,6 +15,13 @@ func s:cleanup_buffers() abort
endfor
endfunc
+func CleanUpTestAuGroup()
+ augroup testing
+ au!
+ augroup END
+ augroup! testing
+endfunc
+
func Test_vim_did_enter()
call assert_false(v:vim_did_enter)
@@ -273,8 +280,8 @@ func Test_win_tab_autocmd()
augroup testing
au WinNew * call add(g:record, 'WinNew')
au WinClosed * call add(g:record, 'WinClosed')
- au WinEnter * call add(g:record, 'WinEnter')
- au WinLeave * call add(g:record, 'WinLeave')
+ au WinEnter * call add(g:record, 'WinEnter')
+ au WinLeave * call add(g:record, 'WinLeave')
au TabNew * call add(g:record, 'TabNew')
au TabClosed * call add(g:record, 'TabClosed')
au TabEnter * call add(g:record, 'TabEnter')
@@ -2010,6 +2017,38 @@ func Test_Cmdline()
au! CmdlineEnter
au! CmdlineLeave
let &shellslash = save_shellslash
+
+ au! CursorMovedC : let g:pos += [getcmdpos()]
+ let g:pos = []
+ call feedkeys(":foo bar baz\<C-W>\<C-W>\<C-W>\<Esc>", 'xt')
+ call assert_equal([2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 9, 5, 1], g:pos)
+ let g:pos = []
+ call feedkeys(":hello\<C-B>\<Esc>", 'xt')
+ call assert_equal([2, 3, 4, 5, 6, 1], g:pos)
+ let g:pos = []
+ call feedkeys(":hello\<C-U>\<Esc>", 'xt')
+ call assert_equal([2, 3, 4, 5, 6, 1], g:pos)
+ let g:pos = []
+ call feedkeys(":hello\<Left>\<C-R>=''\<CR>\<Left>\<Right>\<Esc>", 'xt')
+ call assert_equal([2, 3, 4, 5, 6, 5, 4, 5], g:pos)
+ let g:pos = []
+ call feedkeys(":12345678\<C-R>=setcmdpos(3)??''\<CR>\<Esc>", 'xt')
+ call assert_equal([2, 3, 4, 5, 6, 7, 8, 9, 3], g:pos)
+ let g:pos = []
+ call feedkeys(":12345678\<C-R>=setcmdpos(3)??''\<CR>\<Left>\<Esc>", 'xt')
+ call assert_equal([2, 3, 4, 5, 6, 7, 8, 9, 3, 2], g:pos)
+ au! CursorMovedC
+
+ " setcmdpos() is no-op inside an autocommand
+ au! CursorMovedC : let g:pos += [getcmdpos()] | call setcmdpos(1)
+ let g:pos = []
+ call feedkeys(":hello\<Left>\<Left>\<Esc>", 'xt')
+ call assert_equal([2, 3, 4, 5, 6, 5, 4], g:pos)
+ au! CursorMovedC
+
+ unlet g:entered
+ unlet g:left
+ unlet g:pos
endfunc
" Test for BufWritePre autocommand that deletes or unloads the buffer.
@@ -3738,7 +3777,7 @@ endfunc
func Test_autocmd_split_dummy()
" Autocommand trying to split a window containing a dummy buffer.
- auto BufReadPre * exe "sbuf " .. expand("<abuf>")
+ auto BufReadPre * exe "sbuf " .. expand("<abuf>")
" Avoid the "W11" prompt
au FileChangedShell * let v:fcs_choice = 'reload'
func Xautocmd_changelist()
@@ -4120,4 +4159,23 @@ func Test_BufEnter_botline()
set hidden&vim
endfunc
+" This was using freed memory
+func Test_autocmd_BufWinLeave_with_vsp()
+ new
+ let fname = 'XXXBufWinLeaveUAF.txt'
+ let dummy = 'XXXDummy.txt'
+ call writefile([], fname)
+ call writefile([], dummy)
+ defer delete(fname)
+ defer delete(dummy)
+ exe "e " fname
+ vsp
+ augroup testing
+ exe "au BufWinLeave " .. fname .. " :e " dummy .. "| vsp " .. fname
+ augroup END
+ bw
+ call CleanUpTestAuGroup()
+ exe "bw! " .. dummy
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab