# HG changeset patch # User Bram Moolenaar # Date 1610908204 -3600 # Node ID c6f7df86cd9d50d0dac2c4796817ed6b57bfde69 # Parent 1c9c8221f5460f5a367a2272d410cf6725d69341 patch 8.2.2370: Vim9: command fails in catch block Commit: https://github.com/vim/vim/commit/1430ceeb2d4185a8d60fa81007fbc8b74fd68c46 Author: Bram Moolenaar Date: Sun Jan 17 19:20:32 2021 +0100 patch 8.2.2370: Vim9: command fails in catch block Problem: Vim9: command fails in catch block. Solution: Reset force_abort and need_rethrow. (closes https://github.com/vim/vim/issues/7692) diff --git a/src/testdir/test_vim9_script.vim b/src/testdir/test_vim9_script.vim --- a/src/testdir/test_vim9_script.vim +++ b/src/testdir/test_vim9_script.vim @@ -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 diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -751,6 +751,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 2370, +/**/ 2369, /**/ 2368, diff --git a/src/vim9execute.c b/src/vim9execute.c --- a/src/vim9execute.c +++ b/src/vim9execute.c @@ -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;