patch 9.2.0072: inside_block() uses wrong index in loop
Commit:
https://github.com/vim/vim/commit/1da9d1381f9359652459d4864ac673ff341dafd3
Author: Weixie Cui <
cuiw...@gmail.com>
Date: Fri Feb 27 19:09:34 2026 +0000
patch 9.2.0072: inside_block() uses wrong index in loop
Problem: inside_block() always checks the flags of the top-most stack
entry instead of the current loop index.
Solution: Use the loop index 'i' to check all levels of the condition
stack (Weixie Cui).
closes: #19524
Signed-off-by: Weixie Cui <
cuiw...@gmail.com>
Signed-off-by: Christian Brabandt <
c...@256bit.org>
diff --git a/src/ex_eval.c b/src/ex_eval.c
index c72744555..fa610b72e 100644
--- a/src/ex_eval.c
+++ b/src/ex_eval.c
@@ -1602,7 +1602,7 @@ inside_block(exarg_T *eap)
int i;
for (i = 0; i <= cstack->cs_idx; ++i)
- if (cstack->cs_flags[cstack->cs_idx] & CSF_BLOCK)
+ if (cstack->cs_flags[i] & CSF_BLOCK)
return TRUE;
return FALSE;
}
diff --git a/src/testdir/test_usercommands.vim b/src/testdir/test_usercommands.vim
index a327106bc..5afd8f127 100644
--- a/src/testdir/test_usercommands.vim
+++ b/src/testdir/test_usercommands.vim
@@ -809,6 +809,28 @@ func Test_usercmd_with_block()
endfunc
+" Regression test: inside_block() must check all cstack levels, not just the
+" top. A :normal! inside an :if inside a {} block needs newline-based nextcmd
+" separation to work; the bug was that only cs_flags[cs_idx] was checked.
+func Test_usercmd_block_normal_in_nested_if()
+ let lines =<< trim END
+ vim9script
+ command TestCmd {
+ if true
+ normal! Ahello
+ g:result = 'works'
+ endif
+ }
+ new
+ TestCmd
+ bwipe!
+ END
+ call v9.CheckScriptSuccess(lines)
+ call assert_equal('works', g:result)
+ delcommand TestCmd
+ unlet! g:result
+endfunc
+
func Test_delcommand_buffer()
command Global echo 'global'
command -buffer OneBuffer echo 'one'
diff --git a/src/version.c b/src/version.c
index 4524be1da..11467caea 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 */
+/**/
+ 72,
/**/
71,
/**/