1
0
forked from aniani/vim

patch 8.2.4510: Vim9: shortening commands leads to confusing script

Problem:    Vim9: shortening commands leads to confusing script.
Solution:   In Vim9 script require at least ":cont" for ":continue", "const"
            instead of "cons", "break" instead of "brea", "catch" instead of
            "cat", "else" instead of "el" "elseif" instead of "elsei" "endfor"
            instead of "endfo" "endif" instead of "en" "endtry" instead of
            "endt", "finally" instead of "fina", "throw" instead of "th",
            "while" instead of "wh".
This commit is contained in:
Bram Moolenaar
2022-03-05 12:56:44 +00:00
parent e1d1211799
commit 204852ae2a
7 changed files with 70 additions and 37 deletions

View File

@@ -3745,16 +3745,27 @@ find_ex_command(
(size_t)len) == 0)
{
#ifdef FEAT_EVAL
if (full != NULL
&& cmdnames[(int)eap->cmdidx].cmd_name[len] == NUL)
if (full != NULL && cmdnames[eap->cmdidx].cmd_name[len] == NUL)
*full = TRUE;
#endif
break;
}
// :Print and :mode are not supported in Vim9 script
if (vim9 && (eap->cmdidx == CMD_mode || eap->cmdidx == CMD_Print))
eap->cmdidx = CMD_SIZE;
// :Print and :mode are not supported 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 (eap->cmdidx == CMD_mode || eap->cmdidx == CMD_Print)
eap->cmdidx = CMD_SIZE;
else if (((cmdnames[eap->cmdidx].cmd_argt & EX_WHOLE)
&& len < (int)STRLEN(cmdnames[eap->cmdidx].cmd_name))
|| (eap->cmdidx == CMD_continue && len < 4))
{
semsg(_(e_command_cannot_be_shortened), eap->cmd);
eap->cmdidx = CMD_SIZE;
}
}
// Do not recognize ":*" as the star command unless '*' is in
// 'cpoptions'.
@@ -3775,8 +3786,8 @@ find_ex_command(
eap->cmdidx = CMD_SIZE;
}
// ":fina" means ":finally" for backwards compatibility.
if (eap->cmdidx == CMD_final && p - eap->cmd == 4)
// ":fina" means ":finally" in legacy script, for backwards compatibility.
if (eap->cmdidx == CMD_final && p - eap->cmd == 4 && !vim9)
eap->cmdidx = CMD_finally;
#ifdef FEAT_EVAL