aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/testdir
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2017-03-20 02:48:28 +0100
committerJustin M. Keyes <justinkz@gmail.com>2017-03-22 18:42:16 +0100
commitb9e1289819183f94afb43330a7e0d953869e2af7 (patch)
tree4b2a5116430921f3f93153822a6461f694a88d65 /src/nvim/testdir
parent06ed7a189b2c1dca88f307538b9739b989776068 (diff)
downloadrneovim-b9e1289819183f94afb43330a7e0d953869e2af7.tar.gz
rneovim-b9e1289819183f94afb43330a7e0d953869e2af7.tar.bz2
rneovim-b9e1289819183f94afb43330a7e0d953869e2af7.zip
vim-patch:8.0.0486
Problem: Crash and endless loop when closing windows in a SessionLoadPost autocommand. Solution: Check for valid tabpage. (partly neovim/neovim#6308) https://github.com/vim/vim/commit/8c752bd6c4af54c0b7bac35a39acc2bf16015f85 Closes #6308
Diffstat (limited to 'src/nvim/testdir')
-rw-r--r--src/nvim/testdir/test_autocmd.vim68
1 files changed, 68 insertions, 0 deletions
diff --git a/src/nvim/testdir/test_autocmd.vim b/src/nvim/testdir/test_autocmd.vim
index f05a55f1aa..fe9a3dd451 100644
--- a/src/nvim/testdir/test_autocmd.vim
+++ b/src/nvim/testdir/test_autocmd.vim
@@ -196,3 +196,71 @@ func Test_augroup_deleted()
au! VimEnter
endfunc
+" Closing a window might cause an endless loop
+" E814 for older Vims
+function Test_autocmd_bufwipe_in_SessLoadPost()
+ if has('win32')
+ throw 'Skipped: test hangs on MS-Windows'
+ endif
+ tabnew
+ set noswapfile
+ let g:bufnr=bufnr('%')
+ mksession!
+
+ let content=['set nocp noswapfile',
+ \ 'let v:swapchoice="e"',
+ \ 'augroup test_autocmd_sessionload',
+ \ 'autocmd!',
+ \ 'autocmd SessionLoadPost * 4bw!',
+ \ 'augroup END'
+ \ ]
+ call writefile(content, 'Xvimrc')
+ let a=system(v:progpath. ' --headless -u Xvimrc --noplugins -S Session.vim')
+ call assert_match('E814', a)
+
+ unlet! g:bufnr
+ set swapfile
+ for file in ['Session.vim', 'Xvimrc']
+ call delete(file)
+ endfor
+endfunc
+
+" SEGV occurs in older versions.
+function Test_autocmd_bufwipe_in_SessLoadPost2()
+ if has('win32')
+ throw 'Skipped: test hangs on MS-Windows'
+ endif
+ tabnew
+ set noswapfile
+ let g:bufnr=bufnr('%')
+ mksession!
+
+ let content = ['set nocp noswapfile',
+ \ 'function! DeleteInactiveBufs()',
+ \ ' tabfirst',
+ \ ' let tabblist = []',
+ \ ' for i in range(1, tabpagenr(''$''))',
+ \ ' call extend(tabblist, tabpagebuflist(i))',
+ \ ' endfor',
+ \ ' for b in range(1, bufnr(''$''))',
+ \ ' if bufexists(b) && buflisted(b) && (index(tabblist, b) == -1 || bufname(b) =~# ''^$'')',
+ \ ' exec ''bwipeout '' . b',
+ \ ' endif',
+ \ ' endfor',
+ \ 'call append("1", "SessionLoadPost DONE")',
+ \ 'endfunction',
+ \ 'au SessionLoadPost * call DeleteInactiveBufs()']
+ call writefile(content, 'Xvimrc')
+ let a=system(v:progpath. ' --headless -u Xvimrc --noplugins -S Session.vim')
+ " this probably only matches on unix
+ if has("unix")
+ call assert_notmatch('Caught deadly signal SEGV', a)
+ endif
+ call assert_match('SessionLoadPost DONE', a)
+
+ unlet! g:bufnr
+ set swapfile
+ for file in ['Session.vim', 'Xvimrc']
+ call delete(file)
+ endfor
+endfunc