mirror of
https://github.com/vim/vim.git
synced 2025-10-08 06:04:08 -04:00
patch 8.1.1311: aborting an autocmd with an exception is not tested
Problem: Aborting an autocmd with an exception is not tested. Solution: Add a test. Also shows how to abort a command by throwing an exception.
This commit is contained in:
@@ -1733,3 +1733,22 @@ func Test_ReadWrite_Autocmds()
|
|||||||
call delete('Xtest.c')
|
call delete('Xtest.c')
|
||||||
call delete('test.out')
|
call delete('test.out')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_throw_in_BufWritePre()
|
||||||
|
new
|
||||||
|
call setline(1, ['one', 'two', 'three'])
|
||||||
|
call assert_false(filereadable('Xthefile'))
|
||||||
|
augroup throwing
|
||||||
|
au BufWritePre X* throw 'do not write'
|
||||||
|
augroup END
|
||||||
|
try
|
||||||
|
w Xthefile
|
||||||
|
catch
|
||||||
|
let caught = 1
|
||||||
|
endtry
|
||||||
|
call assert_equal(1, caught)
|
||||||
|
call assert_false(filereadable('Xthefile'))
|
||||||
|
|
||||||
|
bwipe!
|
||||||
|
au! throwing
|
||||||
|
endfunc
|
||||||
|
@@ -767,6 +767,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1311,
|
||||||
/**/
|
/**/
|
||||||
1310,
|
1310,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user