# HG changeset patch # User Bram Moolenaar # Date 1557431105 -7200 # Node ID 24233eeaadd09c665a919298be7ddb2f511b2e36 # Parent 7fb7aeecdf759b2a0f497a172c8c965a3ce2163a patch 8.1.1311: aborting an autocmd with an exception is not tested commit https://github.com/vim/vim/commit/23b5139234a79567097ca73aba15ea134381b934 Author: Bram Moolenaar Date: Thu May 9 21:38:43 2019 +0200 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. diff --git a/src/testdir/test_autocmd.vim b/src/testdir/test_autocmd.vim --- a/src/testdir/test_autocmd.vim +++ b/src/testdir/test_autocmd.vim @@ -1733,3 +1733,22 @@ func Test_ReadWrite_Autocmds() call delete('Xtest.c') 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 diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -768,6 +768,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1311, +/**/ 1310, /**/ 1309,