patch 9.2.0092: control flow commands using '|' fail inside a {} block
Commit:
https://github.com/vim/vim/commit/62cf4c29477a740193157bd92fe882cec9467521
Author: Christian Brabandt <[email protected]>
Date: Mon Mar 2 19:02:06 2026 +0000
patch 9.2.0092: control flow commands using '|' fail inside a {} block
Problem: inside_block() iterates through all cstack levels
and returns TRUE when a CSF_BLOCK frame is found. For control
flow commands this causes '|' to no longer be
recognised as a command separator, breaking
"try | silent cmd | catch | endtry" (Martin Tournoij, after
v9.2.0072).
Solution: Return FALSE from inside_block() for control flow commands
that handle '|' themselves, so they always use '|' as
separator regardless of block nesting.
fixes: #19535
closes: #19543
supported by AI claude.
Signed-off-by: Christian Brabandt <[email protected]>
diff --git a/src/ex_eval.c b/src/ex_eval.c
index fa610b72e..369314d22 100644
--- a/src/ex_eval.c
+++ b/src/ex_eval.c
@@ -1601,6 +1601,28 @@ inside_block(exarg_T *eap)
cstack_T *cstack = eap->cstack;
int i;
+ // Control flow commands handle '|' themselves and must not be treated
+ // as if inside a block even when they are - otherwise '|' separators
+ // in "try | catch | endtry" etc. would not be recognized.
+ switch (eap->cmdidx)
+ {
+ case CMD_if:
+ case CMD_elseif:
+ case CMD_else:
+ case CMD_endif:
+ case CMD_while:
+ case CMD_endwhile:
+ case CMD_for:
+ case CMD_endfor:
+ case CMD_try:
+ case CMD_catch:
+ case CMD_finally:
+ case CMD_endtry:
+ return FALSE;
+ default:
+ break;
+ }
+
for (i = 0; i <= cstack->cs_idx; ++i)
if (cstack->cs_flags[i] & CSF_BLOCK)
return TRUE;
diff --git a/src/testdir/test_trycatch.vim b/src/testdir/test_trycatch.vim
index 0488861f5..44c26dbd6 100644
--- a/src/testdir/test_trycatch.vim
+++ b/src/testdir/test_trycatch.vim
@@ -2375,5 +2375,31 @@ func Test_leave_block_in_endtry_not_called()
endtry
endfunc
+" Ensure | inside_block is correctly executed "{{{1
+func Test_try_endtry_inside_block()
+ let lines =<< trim END
+ vim9script
+
+ augroup testing
+ au User myusertest {
+ try
+ echoerr 'try'
+ catch
+ endtry
+ g:reached_after_endtry = 1
+ }
+ augroup end
+ doautocmd User myusertest
+ END
+ call writefile(lines, 'XtestInsideBlock', 'D')
+ source XtestInsideBlock
+ call assert_equal(1, g:reached_after_endtry)
+ unlet! g:reached_after_endtry
+ augroup testing
+ au!
+ augroup END
+ augroup! testing
+endfunc
+
" Modeline {{{1
" vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker
diff --git a/src/version.c b/src/version.c
index c7daf9114..2ef4469fe 100644
--- a/src/version.c
+++ b/src/version.c
@@ -734,6 +734,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 92,
/**/
91,
/**/
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion visit
https://groups.google.com/d/msgid/vim_dev/E1vx8jP-003Yyo-HK%40256bit.org.