Mercurial > vim
diff src/usercmd.c @ 25469:dcd45fe7fe2e v8.2.3271
patch 8.2.3271: Vim9: cannot use :command or :au with block in :def function
Commit: https://github.com/vim/vim/commit/e4db17fb6e2d029aa2dddfca703ace9bcf0d85fd
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Aug 1 21:19:43 2021 +0200
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.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 01 Aug 2021 21:30:03 +0200 |
parents | 05f9e8f2016c |
children | b9419c9d3da6 |
line wrap: on
line diff
--- a/src/usercmd.c +++ b/src/usercmd.c @@ -983,29 +983,32 @@ may_get_cmd_block(exarg_T *eap, char_u * 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);