mirror of
https://github.com/vim/vim.git
synced 2025-07-26 11:04:33 -04:00
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".
This commit is contained in:
parent
b29ae15977
commit
b2175220da
@ -2761,7 +2761,7 @@ EXTERN char e_type_mismatch_for_v_variable[]
|
|||||||
#endif
|
#endif
|
||||||
EXTERN char e_yank_register_changed_while_using_it[]
|
EXTERN char e_yank_register_changed_while_using_it[]
|
||||||
INIT(= N_("E1064: Yank register changed while using it"));
|
INIT(= N_("E1064: Yank register changed while using it"));
|
||||||
EXTERN char e_command_cannot_be_shortened[]
|
EXTERN char e_command_cannot_be_shortened_str[]
|
||||||
INIT(= N_("E1065: Command cannot be shortened: %s"));
|
INIT(= N_("E1065: Command cannot be shortened: %s"));
|
||||||
#ifdef FEAT_EVAL
|
#ifdef FEAT_EVAL
|
||||||
EXTERN char e_cannot_declare_a_register_str[]
|
EXTERN char e_cannot_declare_a_register_str[]
|
||||||
|
@ -408,7 +408,7 @@ EXCMD(CMD_compiler, "compiler", ex_compiler,
|
|||||||
EX_BANG|EX_TRLBAR|EX_WORD1|EX_CMDWIN|EX_LOCK_OK,
|
EX_BANG|EX_TRLBAR|EX_WORD1|EX_CMDWIN|EX_LOCK_OK,
|
||||||
ADDR_NONE),
|
ADDR_NONE),
|
||||||
EXCMD(CMD_continue, "continue", ex_continue,
|
EXCMD(CMD_continue, "continue", ex_continue,
|
||||||
EX_TRLBAR|EX_SBOXOK|EX_CMDWIN|EX_LOCK_OK,
|
EX_TRLBAR|EX_SBOXOK|EX_CMDWIN|EX_LOCK_OK|EX_WHOLE,
|
||||||
ADDR_NONE),
|
ADDR_NONE),
|
||||||
EXCMD(CMD_confirm, "confirm", ex_wrongmodifier,
|
EXCMD(CMD_confirm, "confirm", ex_wrongmodifier,
|
||||||
EX_NEEDARG|EX_EXTRA|EX_NOTRLCOM|EX_CMDWIN|EX_LOCK_OK,
|
EX_NEEDARG|EX_EXTRA|EX_NOTRLCOM|EX_CMDWIN|EX_LOCK_OK,
|
||||||
@ -567,7 +567,7 @@ EXCMD(CMD_endclass, "endclass", ex_ni,
|
|||||||
EX_EXTRA|EX_TRLBAR|EX_CMDWIN|EX_LOCK_OK,
|
EX_EXTRA|EX_TRLBAR|EX_CMDWIN|EX_LOCK_OK,
|
||||||
ADDR_NONE),
|
ADDR_NONE),
|
||||||
EXCMD(CMD_enddef, "enddef", ex_endfunction,
|
EXCMD(CMD_enddef, "enddef", ex_endfunction,
|
||||||
EX_TRLBAR|EX_CMDWIN|EX_LOCK_OK,
|
EX_TRLBAR|EX_CMDWIN|EX_LOCK_OK|EX_WHOLE,
|
||||||
ADDR_NONE),
|
ADDR_NONE),
|
||||||
EXCMD(CMD_endenum, "endenum", ex_ni,
|
EXCMD(CMD_endenum, "endenum", ex_ni,
|
||||||
EX_EXTRA|EX_TRLBAR|EX_CMDWIN|EX_LOCK_OK,
|
EX_EXTRA|EX_TRLBAR|EX_CMDWIN|EX_LOCK_OK,
|
||||||
@ -603,7 +603,7 @@ EXCMD(CMD_exit, "exit", ex_exit,
|
|||||||
EX_RANGE|EX_WHOLEFOLD|EX_BANG|EX_FILE1|EX_ARGOPT|EX_DFLALL|EX_TRLBAR|EX_CMDWIN|EX_LOCK_OK,
|
EX_RANGE|EX_WHOLEFOLD|EX_BANG|EX_FILE1|EX_ARGOPT|EX_DFLALL|EX_TRLBAR|EX_CMDWIN|EX_LOCK_OK,
|
||||||
ADDR_LINES),
|
ADDR_LINES),
|
||||||
EXCMD(CMD_export, "export", ex_export,
|
EXCMD(CMD_export, "export", ex_export,
|
||||||
EX_EXTRA|EX_NOTRLCOM|EX_EXPR_ARG|EX_CMDWIN|EX_LOCK_OK,
|
EX_EXTRA|EX_NOTRLCOM|EX_EXPR_ARG|EX_CMDWIN|EX_LOCK_OK|EX_WHOLE,
|
||||||
ADDR_NONE),
|
ADDR_NONE),
|
||||||
EXCMD(CMD_exusage, "exusage", ex_exusage,
|
EXCMD(CMD_exusage, "exusage", ex_exusage,
|
||||||
EX_TRLBAR,
|
EX_TRLBAR,
|
||||||
@ -732,7 +732,7 @@ EXCMD(CMD_imenu, "imenu", ex_menu,
|
|||||||
EX_RANGE|EX_ZEROR|EX_EXTRA|EX_TRLBAR|EX_NOTRLCOM|EX_CTRLV|EX_CMDWIN|EX_LOCK_OK,
|
EX_RANGE|EX_ZEROR|EX_EXTRA|EX_TRLBAR|EX_NOTRLCOM|EX_CTRLV|EX_CMDWIN|EX_LOCK_OK,
|
||||||
ADDR_OTHER),
|
ADDR_OTHER),
|
||||||
EXCMD(CMD_import, "import", ex_import,
|
EXCMD(CMD_import, "import", ex_import,
|
||||||
EX_EXTRA|EX_NOTRLCOM|EX_CMDWIN|EX_LOCK_OK,
|
EX_EXTRA|EX_NOTRLCOM|EX_CMDWIN|EX_LOCK_OK|EX_WHOLE,
|
||||||
ADDR_NONE),
|
ADDR_NONE),
|
||||||
EXCMD(CMD_inoremap, "inoremap", ex_map,
|
EXCMD(CMD_inoremap, "inoremap", ex_map,
|
||||||
EX_EXTRA|EX_TRLBAR|EX_NOTRLCOM|EX_CTRLV|EX_CMDWIN|EX_LOCK_OK,
|
EX_EXTRA|EX_TRLBAR|EX_NOTRLCOM|EX_CTRLV|EX_CMDWIN|EX_LOCK_OK,
|
||||||
@ -1281,7 +1281,7 @@ EXCMD(CMD_retab, "retab", ex_retab,
|
|||||||
EX_TRLBAR|EX_RANGE|EX_WHOLEFOLD|EX_DFLALL|EX_BANG|EX_WORD1|EX_CMDWIN|EX_LOCK_OK|EX_MODIFY,
|
EX_TRLBAR|EX_RANGE|EX_WHOLEFOLD|EX_DFLALL|EX_BANG|EX_WORD1|EX_CMDWIN|EX_LOCK_OK|EX_MODIFY,
|
||||||
ADDR_LINES),
|
ADDR_LINES),
|
||||||
EXCMD(CMD_return, "return", ex_return,
|
EXCMD(CMD_return, "return", ex_return,
|
||||||
EX_EXTRA|EX_NOTRLCOM|EX_SBOXOK|EX_CMDWIN|EX_LOCK_OK,
|
EX_EXTRA|EX_NOTRLCOM|EX_SBOXOK|EX_CMDWIN|EX_LOCK_OK|EX_WHOLE,
|
||||||
ADDR_NONE),
|
ADDR_NONE),
|
||||||
EXCMD(CMD_rewind, "rewind", ex_rewind,
|
EXCMD(CMD_rewind, "rewind", ex_rewind,
|
||||||
EX_EXTRA|EX_BANG|EX_CMDARG|EX_ARGOPT|EX_TRLBAR,
|
EX_EXTRA|EX_BANG|EX_CMDARG|EX_ARGOPT|EX_TRLBAR,
|
||||||
|
@ -3753,16 +3753,14 @@ find_ex_command(
|
|||||||
|
|
||||||
// :Print and :mode are not supported in Vim9 script.
|
// :Print and :mode are not supported in Vim9 script.
|
||||||
// Some commands cannot be shortened in Vim9 script.
|
// Some commands cannot be shortened in Vim9 script.
|
||||||
// ":continue" needs at least ":cont", since ":con" looks weird.
|
|
||||||
if (vim9 && eap->cmdidx != CMD_SIZE)
|
if (vim9 && eap->cmdidx != CMD_SIZE)
|
||||||
{
|
{
|
||||||
if (eap->cmdidx == CMD_mode || eap->cmdidx == CMD_Print)
|
if (eap->cmdidx == CMD_mode || eap->cmdidx == CMD_Print)
|
||||||
eap->cmdidx = CMD_SIZE;
|
eap->cmdidx = CMD_SIZE;
|
||||||
else if (((cmdnames[eap->cmdidx].cmd_argt & EX_WHOLE)
|
else if ((cmdnames[eap->cmdidx].cmd_argt & EX_WHOLE)
|
||||||
&& len < (int)STRLEN(cmdnames[eap->cmdidx].cmd_name))
|
&& len < (int)STRLEN(cmdnames[eap->cmdidx].cmd_name))
|
||||||
|| (eap->cmdidx == CMD_continue && len < 4))
|
|
||||||
{
|
{
|
||||||
semsg(_(e_command_cannot_be_shortened), eap->cmd);
|
semsg(_(e_command_cannot_be_shortened_str), eap->cmd);
|
||||||
eap->cmdidx = CMD_SIZE;
|
eap->cmdidx = CMD_SIZE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3381,6 +3381,10 @@ def Test_minimal_command_name_length()
|
|||||||
'cat',
|
'cat',
|
||||||
'catc',
|
'catc',
|
||||||
'con',
|
'con',
|
||||||
|
'cont',
|
||||||
|
'conti',
|
||||||
|
'contin',
|
||||||
|
'continu',
|
||||||
'el',
|
'el',
|
||||||
'els',
|
'els',
|
||||||
'elsei',
|
'elsei',
|
||||||
@ -3391,8 +3395,16 @@ def Test_minimal_command_name_length()
|
|||||||
'endw',
|
'endw',
|
||||||
'endt',
|
'endt',
|
||||||
'endtr',
|
'endtr',
|
||||||
|
'exp',
|
||||||
|
'expo',
|
||||||
|
'expor',
|
||||||
'fina',
|
'fina',
|
||||||
'finall',
|
'finall',
|
||||||
|
'imp',
|
||||||
|
'impo',
|
||||||
|
'impor',
|
||||||
|
'retu',
|
||||||
|
'retur',
|
||||||
'th',
|
'th',
|
||||||
'thr',
|
'thr',
|
||||||
'thro',
|
'thro',
|
||||||
@ -3403,6 +3415,19 @@ def Test_minimal_command_name_length()
|
|||||||
for name in names
|
for name in names
|
||||||
v9.CheckDefAndScriptFailure([name .. ' '], 'E1065:')
|
v9.CheckDefAndScriptFailure([name .. ' '], 'E1065:')
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
|
var lines =<< trim END
|
||||||
|
vim9script
|
||||||
|
def SomeFunc()
|
||||||
|
endd
|
||||||
|
END
|
||||||
|
v9.CheckScriptFailure(lines, 'E1065:')
|
||||||
|
lines =<< trim END
|
||||||
|
vim9script
|
||||||
|
def SomeFunc()
|
||||||
|
endde
|
||||||
|
END
|
||||||
|
v9.CheckScriptFailure(lines, 'E1065:')
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def Test_unset_any_variable()
|
def Test_unset_any_variable()
|
||||||
|
@ -821,6 +821,7 @@ get_function_body(
|
|||||||
{
|
{
|
||||||
int c;
|
int c;
|
||||||
char_u *end;
|
char_u *end;
|
||||||
|
char_u *cmd;
|
||||||
|
|
||||||
// skip ':' and blanks
|
// skip ':' and blanks
|
||||||
for (p = theline; VIM_ISWHITE(*p) || *p == ':'; ++p)
|
for (p = theline; VIM_ISWHITE(*p) || *p == ':'; ++p)
|
||||||
@ -828,12 +829,16 @@ get_function_body(
|
|||||||
|
|
||||||
// Check for "endfunction", "enddef" or "}".
|
// Check for "endfunction", "enddef" or "}".
|
||||||
// When a ":" follows it must be a dict key; "enddef: value,"
|
// When a ":" follows it must be a dict key; "enddef: value,"
|
||||||
|
cmd = p;
|
||||||
if (nesting_inline[nesting]
|
if (nesting_inline[nesting]
|
||||||
? *p == '}'
|
? *p == '}'
|
||||||
: (checkforcmd(&p, nesting_def[nesting]
|
: (checkforcmd(&p, nesting_def[nesting]
|
||||||
? "enddef" : "endfunction", 4)
|
? "enddef" : "endfunction", 4)
|
||||||
&& *p != ':'))
|
&& *p != ':'))
|
||||||
{
|
{
|
||||||
|
if (!nesting_inline[nesting] && nesting_def[nesting]
|
||||||
|
&& p < cmd + 6)
|
||||||
|
semsg(_(e_command_cannot_be_shortened_str), "enddef");
|
||||||
if (nesting-- == 0)
|
if (nesting-- == 0)
|
||||||
{
|
{
|
||||||
char_u *nextcmd = NULL;
|
char_u *nextcmd = NULL;
|
||||||
|
@ -754,6 +754,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
4514,
|
||||||
/**/
|
/**/
|
||||||
4513,
|
4513,
|
||||||
/**/
|
/**/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user