]> granicus.if.org Git - vim/commitdiff
patch 8.1.1311: aborting an autocmd with an exception is not tested v8.1.1311
authorBram Moolenaar <Bram@vim.org>
Thu, 9 May 2019 19:38:43 +0000 (21:38 +0200)
committerBram Moolenaar <Bram@vim.org>
Thu, 9 May 2019 19:38:43 +0000 (21:38 +0200)
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.

src/testdir/test_autocmd.vim
src/version.c

index 55d725e48aaba49499611c8d0993c4005ebc0226..48db3e2a996d8b58b4874d05cdbd7e33cf1c0567 100644 (file)
@@ -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
index 57aff32d6dc0237e9a7027e3f9c3327faddce373..a9b376e23bc14ac7486defb1c40641e4ccd7f986 100644 (file)
@@ -767,6 +767,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1311,
 /**/
     1310,
 /**/