summaryrefslogtreecommitdiff
path: root/src/usercmd.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2021-08-01 21:19:43 +0200
committerBram Moolenaar <Bram@vim.org>2021-08-01 21:19:43 +0200
commite4db17fb6e2d029aa2dddfca703ace9bcf0d85fd (patch)
tree8e74fd7a45bdc270a77992cc04293ee0c5a6b8de /src/usercmd.c
parent0d4d9ee9bb18f89d76c67f037baebe2c2db545f0 (diff)
downloadvim-git-e4db17fb6e2d029aa2dddfca703ace9bcf0d85fd.tar.gz
patch 8.2.3271: Vim9: cannot use :command or :au with block in :def functionv8.2.3271
Problem: Vim9: cannot use :command or :au with a block in a :def function. Solution: Recognize the start of the block.
Diffstat (limited to 'src/usercmd.c')
-rw-r--r--src/usercmd.c35
1 files changed, 19 insertions, 16 deletions
diff --git a/src/usercmd.c b/src/usercmd.c
index 48f84b1c3..41f8e0476 100644
--- a/src/usercmd.c
+++ b/src/usercmd.c
@@ -983,29 +983,32 @@ may_get_cmd_block(exarg_T *eap, char_u *p, char_u **tofree, int *flags)
if (*p == '{' && ends_excmd2(eap->arg, skipwhite(p + 1))
&& eap->getline != NULL)
{
- garray_T ga;
- char_u *line = NULL;
+ garray_T ga;
+ char_u *line = NULL;
ga_init2(&ga, sizeof(char_u *), 10);
if (ga_add_string(&ga, p) == FAIL)
return retp;
- // Read lines between '{' and '}'. Does not support nesting or
- // here-doc constructs.
- for (;;)
- {
- vim_free(line);
- if ((line = eap->getline(':', eap->cookie,
- 0, GETLINE_CONCAT_CONTBAR)) == NULL)
+ // If the argument ends in "}" it must have been concatenated already
+ // for ISN_EXEC.
+ if (p[STRLEN(p) - 1] != '}')
+ // Read lines between '{' and '}'. Does not support nesting or
+ // here-doc constructs.
+ for (;;)
{
- emsg(_(e_missing_rcurly));
- break;
+ vim_free(line);
+ if ((line = eap->getline(':', eap->cookie,
+ 0, GETLINE_CONCAT_CONTBAR)) == NULL)
+ {
+ emsg(_(e_missing_rcurly));
+ break;
+ }
+ if (ga_add_string(&ga, line) == FAIL)
+ break;
+ if (*skipwhite(line) == '}')
+ break;
}
- if (ga_add_string(&ga, line) == FAIL)
- break;
- if (*skipwhite(line) == '}')
- break;
- }
vim_free(line);
retp = *tofree = ga_concat_strings(&ga, "\n");
ga_clear_strings(&ga);