Mercurial > vim
comparison 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 |
comparison
equal
deleted
inserted
replaced
25468:0290badbbf7b | 25469:dcd45fe7fe2e |
---|---|
981 char_u *retp = p; | 981 char_u *retp = p; |
982 | 982 |
983 if (*p == '{' && ends_excmd2(eap->arg, skipwhite(p + 1)) | 983 if (*p == '{' && ends_excmd2(eap->arg, skipwhite(p + 1)) |
984 && eap->getline != NULL) | 984 && eap->getline != NULL) |
985 { | 985 { |
986 garray_T ga; | 986 garray_T ga; |
987 char_u *line = NULL; | 987 char_u *line = NULL; |
988 | 988 |
989 ga_init2(&ga, sizeof(char_u *), 10); | 989 ga_init2(&ga, sizeof(char_u *), 10); |
990 if (ga_add_string(&ga, p) == FAIL) | 990 if (ga_add_string(&ga, p) == FAIL) |
991 return retp; | 991 return retp; |
992 | 992 |
993 // Read lines between '{' and '}'. Does not support nesting or | 993 // If the argument ends in "}" it must have been concatenated already |
994 // here-doc constructs. | 994 // for ISN_EXEC. |
995 for (;;) | 995 if (p[STRLEN(p) - 1] != '}') |
996 { | 996 // Read lines between '{' and '}'. Does not support nesting or |
997 vim_free(line); | 997 // here-doc constructs. |
998 if ((line = eap->getline(':', eap->cookie, | 998 for (;;) |
999 0, GETLINE_CONCAT_CONTBAR)) == NULL) | 999 { |
1000 { | 1000 vim_free(line); |
1001 emsg(_(e_missing_rcurly)); | 1001 if ((line = eap->getline(':', eap->cookie, |
1002 break; | 1002 0, GETLINE_CONCAT_CONTBAR)) == NULL) |
1003 } | 1003 { |
1004 if (ga_add_string(&ga, line) == FAIL) | 1004 emsg(_(e_missing_rcurly)); |
1005 break; | 1005 break; |
1006 if (*skipwhite(line) == '}') | 1006 } |
1007 break; | 1007 if (ga_add_string(&ga, line) == FAIL) |
1008 } | 1008 break; |
1009 if (*skipwhite(line) == '}') | |
1010 break; | |
1011 } | |
1009 vim_free(line); | 1012 vim_free(line); |
1010 retp = *tofree = ga_concat_strings(&ga, "\n"); | 1013 retp = *tofree = ga_concat_strings(&ga, "\n"); |
1011 ga_clear_strings(&ga); | 1014 ga_clear_strings(&ga); |
1012 *flags |= UC_VIM9; | 1015 *flags |= UC_VIM9; |
1013 } | 1016 } |