Mercurial > vim
comparison src/testdir/test_trycatch.vim @ 23191:3e7723bab4e5 v8.2.2141
patch 8.2.2141: a user command with try/catch may not catch an expression error
Commit: https://github.com/vim/vim/commit/8143a53c533bc7776c57e5db063d185bdd5750f3
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Dec 13 20:26:29 2020 +0100
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 https://github.com/vim/vim/issues/7469)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 13 Dec 2020 20:30:04 +0100 |
parents | 03249b8976a9 |
children | e855eba4ac39 |
comparison
equal
deleted
inserted
replaced
23190:42b507fffe8f | 23191:3e7723bab4e5 |
---|---|
2197 augroup END | 2197 augroup END |
2198 augroup! bufenter_exception | 2198 augroup! bufenter_exception |
2199 %bwipe! | 2199 %bwipe! |
2200 endfunc | 2200 endfunc |
2201 | 2201 |
2202 " Test for using try/catch in a user command with a failing expression {{{1 | |
2203 func Test_user_command_try_catch() | |
2204 let lines =<< trim END | |
2205 function s:throw() abort | |
2206 throw 'error' | |
2207 endfunction | |
2208 | |
2209 command! Execute | |
2210 \ try | |
2211 \ | let s:x = s:throw() | |
2212 \ | catch | |
2213 \ | let g:caught = 'caught' | |
2214 \ | endtry | |
2215 | |
2216 let g:caught = 'no' | |
2217 Execute | |
2218 call assert_equal('caught', g:caught) | |
2219 END | |
2220 call writefile(lines, 'XtestTryCatch') | |
2221 source XtestTryCatch | |
2222 | |
2223 call delete('XtestTryCatch') | |
2224 unlet g:caught | |
2225 endfunc | |
2226 | |
2202 " Modeline {{{1 | 2227 " Modeline {{{1 |
2203 " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker | 2228 " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker |