diff options
author | zeertzjq <zeertzjq@outlook.com> | 2023-05-05 20:48:25 +0800 |
---|---|---|
committer | zeertzjq <zeertzjq@outlook.com> | 2023-05-06 07:47:43 +0800 |
commit | ad7f9a701cf25f598cb8ee3d05ad0604fa9a9a65 (patch) | |
tree | 659e3add44e7ddcc773e01818155ca7ffb98489d /test | |
parent | aa5f3a7962c3b96d1a939a83bf2dacad72d8e898 (diff) | |
download | rneovim-ad7f9a701cf25f598cb8ee3d05ad0604fa9a9a65.tar.gz rneovim-ad7f9a701cf25f598cb8ee3d05ad0604fa9a9a65.tar.bz2 rneovim-ad7f9a701cf25f598cb8ee3d05ad0604fa9a9a65.zip |
vim-patch:8.2.2141: a user command with try/catch may not catch an expression error
Problem: A user command with try/catch may not catch an expression error.
Solution: When an expression fails check for following "|". (closes vim/vim#7469)
https://github.com/vim/vim/commit/8143a53c533bc7776c57e5db063d185bdd5750f3
Co-authored-by: Bram Moolenaar <Bram@vim.org>
Diffstat (limited to 'test')
-rw-r--r-- | test/old/testdir/test_trycatch.vim | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/test/old/testdir/test_trycatch.vim b/test/old/testdir/test_trycatch.vim index ef20e03126..a87b753a34 100644 --- a/test/old/testdir/test_trycatch.vim +++ b/test/old/testdir/test_trycatch.vim @@ -2220,6 +2220,31 @@ func Test_BufEnter_exception() %bwipe! 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 func Test_user_command_throw_in_function_call() let lines =<< trim END |