comparison src/userfunc.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 e3f1086429d8
children 9a4cb96c9550
comparison
equal deleted inserted replaced
25468:0290badbbf7b 25469:dcd45fe7fe2e
901 end = p + STRLEN(p) - 1; 901 end = p + STRLEN(p) - 1;
902 while (end > p && VIM_ISWHITE(*end)) 902 while (end > p && VIM_ISWHITE(*end))
903 --end; 903 --end;
904 if (end > p && *end == '{') 904 if (end > p && *end == '{')
905 { 905 {
906 int is_block;
907
908 // check for trailing "=> {": start of an inline function
906 --end; 909 --end;
907 while (end > p && VIM_ISWHITE(*end)) 910 while (end > p && VIM_ISWHITE(*end))
908 --end; 911 --end;
909 if (end > p + 2 && end[-1] == '=' && end[0] == '>') 912 is_block = end > p + 2 && end[-1] == '=' && end[0] == '>';
913 if (!is_block)
910 { 914 {
911 // found trailing "=> {", start of an inline function 915 char_u *s = p;
916
917 // check for line starting with "au" for :autocmd or
918 // "com" for :command, these can use a {} block
919 is_block = checkforcmd_noparen(&s, "autocmd", 2)
920 || checkforcmd_noparen(&s, "command", 3);
921 }
922
923 if (is_block)
924 {
912 if (nesting == MAX_FUNC_NESTING - 1) 925 if (nesting == MAX_FUNC_NESTING - 1)
913 emsg(_(e_function_nesting_too_deep)); 926 emsg(_(e_function_nesting_too_deep));
914 else 927 else
915 { 928 {
916 ++nesting; 929 ++nesting;