0
0
mirror of https://github.com/vim/vim.git synced 2025-09-25 03:54:15 -04:00

patch 8.2.3271: Vim9: cannot use :command or :au with block in :def function

Problem:    Vim9: cannot use :command or :au with a block in a :def function.
Solution:   Recognize the start of the block.
This commit is contained in:
Bram Moolenaar
2021-08-01 21:19:43 +02:00
parent 0d4d9ee9bb
commit e4db17fb6e
7 changed files with 98 additions and 20 deletions

View File

@@ -903,12 +903,25 @@ get_function_body(
--end;
if (end > p && *end == '{')
{
int is_block;
// check for trailing "=> {": start of an inline function
--end;
while (end > p && VIM_ISWHITE(*end))
--end;
if (end > p + 2 && end[-1] == '=' && end[0] == '>')
is_block = end > p + 2 && end[-1] == '=' && end[0] == '>';
if (!is_block)
{
char_u *s = p;
// check for line starting with "au" for :autocmd or
// "com" for :command, these can use a {} block
is_block = checkforcmd_noparen(&s, "autocmd", 2)
|| checkforcmd_noparen(&s, "command", 3);
}
if (is_block)
{
// found trailing "=> {", start of an inline function
if (nesting == MAX_FUNC_NESTING - 1)
emsg(_(e_function_nesting_too_deep));
else