File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2158,7 +2158,10 @@ eval0(
21582158 semsg (_ (e_invexpr2 ), arg );
21592159
21602160 // Some of the expression may not have been consumed. Do not check for
2161- // a next command to avoid more errors.
2161+ // a next command to avoid more errors, unless "|" is following, which
2162+ // could only be a command separator.
2163+ if (eap != NULL && skipwhite (p )[0 ] == '|' && skipwhite (p )[1 ] != '|' )
2164+ eap -> nextcmd = check_nextcmd (p );
21622165 return FAIL ;
21632166 }
21642167
Original file line number Diff line number Diff line change @@ -2199,5 +2199,30 @@ func Test_BufEnter_exception()
21992199 % bwipe!
22002200endfunc
22012201
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+
22022227" Modeline {{{1
22032228" vim: ts = 8 sw = 2 sts = 2 expandtab tw = 80 fdm = marker
Original file line number Diff line number Diff line change @@ -6825,7 +6825,7 @@ func Test_script_lines()
68256825 \ ])
68266826 call assert_report (" Shouldn't be able to define function" )
68276827 catch
6828- call assert_exception (' Vim(function):E126 : Missing :endfunction ' )
6828+ call assert_exception (' Vim(function):E1145 : Missing heredoc end marker: . ' )
68296829 endtry
68306830
68316831 " :change
@@ -6845,7 +6845,7 @@ func Test_script_lines()
68456845 \ ])
68466846 call assert_report (" Shouldn't be able to define function" )
68476847 catch
6848- call assert_exception (' Vim(function):E126 : Missing :endfunction ' )
6848+ call assert_exception (' Vim(function):E1145 : Missing heredoc end marker: . ' )
68496849 endtry
68506850
68516851 " :insert
@@ -6865,7 +6865,7 @@ func Test_script_lines()
68656865 \ ])
68666866 call assert_report (" Shouldn't be able to define function" )
68676867 catch
6868- call assert_exception (' Vim(function):E126 : Missing :endfunction ' )
6868+ call assert_exception (' Vim(function):E1145 : Missing heredoc end marker: . ' )
68696869 endtry
68706870endfunc
68716871
Original file line number Diff line number Diff line change @@ -750,6 +750,8 @@ static char *(features[]) =
750750
751751static int included_patches [] =
752752{ /* Add new patch number below this line */
753+ /**/
754+ 2141 ,
753755/**/
754756 2140 ,
755757/**/
You can’t perform that action at this time.
0 commit comments