From 1430ceeb2d4185a8d60fa81007fbc8b74fd68c46 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sun, 17 Jan 2021 19:20:32 +0100 Subject: 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 #7692) --- src/testdir/test_vim9_script.vim | 37 +++++++++++++++++++++++++++++++++++++ src/version.c | 2 ++ src/vim9execute.c | 1 + 3 files changed, 40 insertions(+) diff --git a/src/testdir/test_vim9_script.vim b/src/testdir/test_vim9_script.vim index 158c64c27..478c39460 100644 --- 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 index 3ac6cfae8..ecb0c4355 100644 --- a/src/version.c +++ b/src/version.c @@ -750,6 +750,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 2370, /**/ 2369, /**/ diff --git a/src/vim9execute.c b/src/vim9execute.c index b24475ecf..fdc49eb05 100644 --- 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; -- cgit v1.2.1