Mercurial > vim
changeset 16617:24233eeaadd0 v8.1.1311
patch 8.1.1311: aborting an autocmd with an exception is not tested
commit https://github.com/vim/vim/commit/23b5139234a79567097ca73aba15ea134381b934
Author: Bram Moolenaar <Bram@vim.org>
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.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 09 May 2019 21:45:05 +0200 |
parents | 7fb7aeecdf75 |
children | b017e632e336 |
files | src/testdir/test_autocmd.vim src/version.c |
diffstat | 2 files changed, 21 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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