From 01ddb39699c2d84386c2a08c94ee9c175917a4ef Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sun, 4 Aug 2019 19:54:17 -0400 Subject: 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. https://github.com/vim/vim/commit/23b5139234a79567097ca73aba15ea134381b934 --- src/nvim/testdir/test_autocmd.vim | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src') diff --git a/src/nvim/testdir/test_autocmd.vim b/src/nvim/testdir/test_autocmd.vim index ddd0643feb..b686d0292f 100644 --- a/src/nvim/testdir/test_autocmd.vim +++ b/src/nvim/testdir/test_autocmd.vim @@ -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 -- cgit