]> granicus.if.org Git - vim/commitdiff
patch 8.2.2370: Vim9: command fails in catch block v8.2.2370
authorBram Moolenaar <Bram@vim.org>
Sun, 17 Jan 2021 18:20:32 +0000 (19:20 +0100)
committerBram Moolenaar <Bram@vim.org>
Sun, 17 Jan 2021 18:20:32 +0000 (19:20 +0100)
Problem:    Vim9: command fails in catch block.
Solution:   Reset force_abort and need_rethrow. (closes #7692)

src/testdir/test_vim9_script.vim
src/version.c
src/vim9execute.c

index 158c64c27c091f08780f95a7045b0810f7613f9f..478c394603fe87fc9d0fad1f79adbe2d5f9f6b99 100644 (file)
@@ -558,6 +558,43 @@ def Test_try_catch_throw()
   assert_equal(411, n)
 enddef
 
+def Test_cnext_works_in_catch()
+  var lines =<< trim END
+      vim9script
+      au BufEnter * eval 0
+      writefile(['text'], 'Xfile1')
+      writefile(['text'], 'Xfile2')
+      var items = [
+          {lnum: 1, filename: 'Xfile1', valid: true},
+          {lnum: 1, filename: 'Xfile2', valid: true}
+        ]
+      setqflist([], ' ', {items: items})
+      cwindow
+
+      def CnextOrCfirst()
+        # if cnext fails, cfirst is used
+        try
+          cnext
+        catch
+          cfirst
+        endtry
+      enddef
+
+      CnextOrCfirst()
+      CnextOrCfirst()
+      writefile([getqflist({idx: 0}).idx], 'Xresult')
+      qall
+  END
+  writefile(lines, 'XCatchCnext')
+  RunVim([], [], '--clean -S XCatchCnext')
+  assert_equal(['1'], readfile('Xresult'))
+
+  delete('Xfile1')
+  delete('Xfile2')
+  delete('XCatchCnext')
+  delete('Xresult')
+enddef
+
 def Test_throw_skipped()
   if 0
     throw dontgethere
index 3ac6cfae81c9bd7499fc6ad652e2d39f4c805612..ecb0c4355e51b68df5709bb3673d35d1b9b523fd 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2370,
 /**/
     2369,
 /**/
index b24475ecfedb475a18c2dc4dcb106efe8404a9c4..fdc49eb05d2535a0670a123fc50f7f593c05d77b 100644 (file)
@@ -2572,6 +2572,7 @@ call_def_function(
                        trycmd->tcd_caught = TRUE;
                    }
                    did_emsg = got_int = did_throw = FALSE;
+                   force_abort = need_rethrow = FALSE;
                    catch_exception(current_exception);
                }
                break;