aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2019-08-04 19:54:17 -0400
committerJustin M. Keyes <justinkz@gmail.com>2019-08-05 01:54:17 +0200
commit01ddb39699c2d84386c2a08c94ee9c175917a4ef (patch)
treefae96e523de280b7bdeeea6973e069f351c745a8
parenta724209b5a34e40fe2fff338ff7c5db2bc395bbc (diff)
downloadrneovim-01ddb39699c2d84386c2a08c94ee9c175917a4ef.tar.gz
rneovim-01ddb39699c2d84386c2a08c94ee9c175917a4ef.tar.bz2
rneovim-01ddb39699c2d84386c2a08c94ee9c175917a4ef.zip
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
-rw-r--r--src/nvim/testdir/test_autocmd.vim19
1 files changed, 19 insertions, 0 deletions
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