comparison src/userfunc.c @ 27978:442ca2007bec v8.2.4514

patch 8.2.4514: Vim9: some flow commands can be shortened Commit: https://github.com/vim/vim/commit/b2175220dafc28349b275ac7f3080f89cce78a57 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Mar 5 20:24:41 2022 +0000 patch 8.2.4514: Vim9: some flow commands can be shortened Problem: Vim9: some flow commands can be shortened. Solution: Also require using the full name for ":return", ":enddef", ":continue", ":export" and ":import".
author Bram Moolenaar <Bram@vim.org>
date Sat, 05 Mar 2022 21:30:03 +0100
parents 8e630053c59c
children 02f787034998
comparison
equal deleted inserted replaced
27977:9432710dac71 27978:442ca2007bec
819 } 819 }
820 else 820 else
821 { 821 {
822 int c; 822 int c;
823 char_u *end; 823 char_u *end;
824 char_u *cmd;
824 825
825 // skip ':' and blanks 826 // skip ':' and blanks
826 for (p = theline; VIM_ISWHITE(*p) || *p == ':'; ++p) 827 for (p = theline; VIM_ISWHITE(*p) || *p == ':'; ++p)
827 ; 828 ;
828 829
829 // Check for "endfunction", "enddef" or "}". 830 // Check for "endfunction", "enddef" or "}".
830 // When a ":" follows it must be a dict key; "enddef: value," 831 // When a ":" follows it must be a dict key; "enddef: value,"
832 cmd = p;
831 if (nesting_inline[nesting] 833 if (nesting_inline[nesting]
832 ? *p == '}' 834 ? *p == '}'
833 : (checkforcmd(&p, nesting_def[nesting] 835 : (checkforcmd(&p, nesting_def[nesting]
834 ? "enddef" : "endfunction", 4) 836 ? "enddef" : "endfunction", 4)
835 && *p != ':')) 837 && *p != ':'))
836 { 838 {
839 if (!nesting_inline[nesting] && nesting_def[nesting]
840 && p < cmd + 6)
841 semsg(_(e_command_cannot_be_shortened_str), "enddef");
837 if (nesting-- == 0) 842 if (nesting-- == 0)
838 { 843 {
839 char_u *nextcmd = NULL; 844 char_u *nextcmd = NULL;
840 845
841 if (*p == '|' || *p == '}') 846 if (*p == '|' || *p == '}')