From: Weixie Cui Date: Fri, 27 Feb 2026 19:09:34 +0000 (+0000) Subject: patch 9.2.0072: inside_block() uses wrong index in loop X-Git-Tag: v9.2.0072^0 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=1da9d1381f9359652459d4864ac673ff341dafd3;p=thirdparty%2Fvim.git 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 Signed-off-by: Christian Brabandt --- diff --git a/src/ex_eval.c b/src/ex_eval.c index c72744555d..fa610b72ea 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 a327106bc5..5afd8f1278 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 4524be1da5..11467caeaa 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, /**/