mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:8.1.1311: test: abort autocmd with exception #10692
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.
23b5139234
This commit is contained in:
parent
a724209b5a
commit
01ddb39699
@ -1673,6 +1673,25 @@ func Test_ReadWrite_Autocmds()
|
||||
call delete('test.out')
|
||||
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
|
||||
|
||||
func Test_FileChangedShell_reload()
|
||||
if !has('unix')
|
||||
return
|
||||
|
Loading…
Reference in New Issue
Block a user