mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 03:18:16 +00:00
Merge pull request #23488 from zeertzjq/vim-8.2.2094
vim-patch:8.2.{2094,2141},9.0.1508
This commit is contained in:
@@ -2367,7 +2367,17 @@ int eval0(char *arg, typval_T *rettv, exarg_T *eap, evalarg_T *const evalarg)
|
|||||||
semsg(_(e_invexpr2), arg);
|
semsg(_(e_invexpr2), arg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ret = FAIL;
|
|
||||||
|
if (eap != NULL && p != NULL) {
|
||||||
|
// Some of the expression may not have been consumed.
|
||||||
|
// Only execute a next command if it cannot be a "||" operator.
|
||||||
|
// The next command may be "catch".
|
||||||
|
char *nextcmd = check_nextcmd(p);
|
||||||
|
if (nextcmd != NULL && *nextcmd != '|') {
|
||||||
|
eap->nextcmd = nextcmd;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (eap != NULL) {
|
if (eap != NULL) {
|
||||||
|
@@ -2220,6 +2220,61 @@ func Test_BufEnter_exception()
|
|||||||
%bwipe!
|
%bwipe!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" Test for using try/catch when lines are joined by "|" or "\n" {{{1
|
||||||
|
func Test_try_catch_nextcmd()
|
||||||
|
func Throw()
|
||||||
|
throw "Failure"
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
let lines =<< trim END
|
||||||
|
try
|
||||||
|
let s:x = Throw()
|
||||||
|
catch
|
||||||
|
let g:caught = 1
|
||||||
|
endtry
|
||||||
|
END
|
||||||
|
|
||||||
|
let g:caught = 0
|
||||||
|
call execute(lines)
|
||||||
|
call assert_equal(1, g:caught)
|
||||||
|
|
||||||
|
let g:caught = 0
|
||||||
|
call execute(join(lines, '|'))
|
||||||
|
call assert_equal(1, g:caught)
|
||||||
|
|
||||||
|
let g:caught = 0
|
||||||
|
call execute(join(lines, "\n"))
|
||||||
|
call assert_equal(1, g:caught)
|
||||||
|
|
||||||
|
unlet g:caught
|
||||||
|
delfunc Throw
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
" Test for using try/catch in a user command with a failing expression {{{1
|
||||||
|
func Test_user_command_try_catch()
|
||||||
|
let lines =<< trim END
|
||||||
|
function s:throw() abort
|
||||||
|
throw 'error'
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
command! Execute
|
||||||
|
\ try
|
||||||
|
\ | let s:x = s:throw()
|
||||||
|
\ | catch
|
||||||
|
\ | let g:caught = 'caught'
|
||||||
|
\ | endtry
|
||||||
|
|
||||||
|
let g:caught = 'no'
|
||||||
|
Execute
|
||||||
|
call assert_equal('caught', g:caught)
|
||||||
|
END
|
||||||
|
call writefile(lines, 'XtestTryCatch')
|
||||||
|
source XtestTryCatch
|
||||||
|
|
||||||
|
call delete('XtestTryCatch')
|
||||||
|
unlet g:caught
|
||||||
|
endfunc
|
||||||
|
|
||||||
" Test for using throw in a called function with following error {{{1
|
" Test for using throw in a called function with following error {{{1
|
||||||
func Test_user_command_throw_in_function_call()
|
func Test_user_command_throw_in_function_call()
|
||||||
let lines =<< trim END
|
let lines =<< trim END
|
||||||
|
Reference in New Issue
Block a user