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 <cuiweixie@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
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;
}
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'
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 72,
/**/
71,
/**/