vim-patch:8.2.5027: error for missing :endif when an exception was thrown

Problem:    Error for missing :endif when an exception was thrown. (Dani
            Dickstein)
Solution:   Do not give an error when aborting. (closes vim/vim#10490)

bf79a4e48d

Co-authored-by: Bram Moolenaar <Bram@vim.org>
This commit is contained in:
zeertzjq
2022-11-05 14:26:28 +08:00
parent 48405df046
commit 30cfdd0ea1
2 changed files with 18 additions and 1 deletions

View File

@@ -726,7 +726,7 @@ int do_cmdline(char *cmdline, LineGetter fgetline, void *cookie, int flags)
if (cstack.cs_idx >= 0) { if (cstack.cs_idx >= 0) {
// If a sourced file or executed function ran to its end, report the // If a sourced file or executed function ran to its end, report the
// unclosed conditional. // unclosed conditional.
if (!got_int && !did_throw if (!got_int && !did_throw && !aborting()
&& ((getline_equal(fgetline, cookie, getsourceline) && ((getline_equal(fgetline, cookie, getsourceline)
&& !source_finished(fgetline, cookie)) && !source_finished(fgetline, cookie))
|| (getline_equal(fgetline, cookie, get_func_line) || (getline_equal(fgetline, cookie, get_func_line)

View File

@@ -2221,6 +2221,23 @@ func Test_user_command_throw_in_function_call()
unlet g:caught unlet g:caught
endfunc endfunc
" Test that after reporting an uncaught exception there is no error for a
" missing :endif
func Test_after_exception_no_endif_error()
function Throw()
throw "Failure"
endfunction
function Foo()
if 1
call Throw()
endif
endfunction
call assert_fails('call Foo()', ['E605:', 'E605:'])
delfunc Throw
delfunc Foo
endfunc
" Test for using throw in a called function with following endtry {{{1 " Test for using throw in a called function with following endtry {{{1
func Test_user_command_function_call_with_endtry() func Test_user_command_function_call_with_endtry()
let lines =<< trim END let lines =<< trim END