Mercurial > vim
comparison src/testdir/test_autocmd.vim @ 11199:e08ead1d269f v8.0.0486
patch 8.0.0486: crash and endless loop when closing windows in autocmd
commit https://github.com/vim/vim/commit/8c752bd6c4af54c0b7bac35a39acc2bf16015f85
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Mar 19 17:09:56 2017 +0100
patch 8.0.0486: crash and endless loop when closing windows in autocmd
Problem: Crash and endless loop when closing windows in a SessionLoadPost
autocommand.
Solution: Check for valid tabpage. (partly neovim #6308)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sun, 19 Mar 2017 17:15:05 +0100 |
parents | 7f355d8cd634 |
children | 87ef152072d4 |
comparison
equal
deleted
inserted
replaced
11198:011eb80f6e66 | 11199:e08ead1d269f |
---|---|
343 bwipe! | 343 bwipe! |
344 | 344 |
345 call delete('Xdir', 'd') | 345 call delete('Xdir', 'd') |
346 au! BufEnter | 346 au! BufEnter |
347 endfunc | 347 endfunc |
348 | |
349 " Closing a window might cause an endless loop | |
350 " E814 for older Vims | |
351 function Test_autocmd_bufwipe_in_SessLoadPost() | |
352 tabnew | |
353 set noswapfile | |
354 let g:bufnr=bufnr('%') | |
355 mksession! | |
356 | |
357 let content=['set nocp noswapfile', | |
358 \ 'let v:swapchoice="e"', | |
359 \ 'augroup test_autocmd_sessionload', | |
360 \ 'autocmd!', | |
361 \ 'autocmd SessionLoadPost * 4bw!', | |
362 \ 'augroup END' | |
363 \ ] | |
364 call writefile(content, 'Xvimrc') | |
365 let a=system(v:progpath. ' -u Xvimrc --noplugins -S Session.vim') | |
366 call assert_match('E814', a) | |
367 | |
368 unlet! g:bufnr | |
369 set swapfile | |
370 for file in ['Session.vim', 'Xvimrc'] | |
371 call delete(file) | |
372 endfor | |
373 endfunc | |
374 | |
375 " SEGV occurs in older versions. | |
376 function Test_autocmd_bufwipe_in_SessLoadPost2() | |
377 tabnew | |
378 set noswapfile | |
379 let g:bufnr=bufnr('%') | |
380 mksession! | |
381 | |
382 let content = ['set nocp noswapfile', | |
383 \ 'function! DeleteInactiveBufs()', | |
384 \ ' tabfirst', | |
385 \ ' let tabblist = []', | |
386 \ ' for i in range(1, tabpagenr(''$''))', | |
387 \ ' call extend(tabblist, tabpagebuflist(i))', | |
388 \ ' endfor', | |
389 \ ' for b in range(1, bufnr(''$''))', | |
390 \ ' if bufexists(b) && buflisted(b) && (index(tabblist, b) == -1 || bufname(b) =~# ''^$'')', | |
391 \ ' exec ''bwipeout '' . b', | |
392 \ ' endif', | |
393 \ ' endfor', | |
394 \ 'call append("1", "SessionLoadPost DONE")', | |
395 \ 'endfunction', | |
396 \ 'au SessionLoadPost * call DeleteInactiveBufs()'] | |
397 call writefile(content, 'Xvimrc') | |
398 let a=system(v:progpath. ' -u Xvimrc --noplugins -S Session.vim') | |
399 " this probably only matches on unix | |
400 if has("unix") | |
401 call assert_notmatch('Caught deadly signal SEGV', a) | |
402 endif | |
403 call assert_match('SessionLoadPost DONE', a) | |
404 | |
405 unlet! g:bufnr | |
406 set swapfile | |
407 for file in ['Session.vim', 'Xvimrc'] | |
408 call delete(file) | |
409 endfor | |
410 endfunc |