summaryrefslogtreecommitdiffstats
path: root/src/ex_docmd.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2022-03-05 12:56:44 +0000
committerBram Moolenaar <Bram@vim.org>2022-03-05 12:56:44 +0000
commit204852ae2adfdde10c656ca7f14e5b4207a69172 (patch)
tree67b62ce1a926faaeff341efa797baa3da5fd2326 /src/ex_docmd.c
parente1d1211799bc37c063666e97437cf4e9af4782b0 (diff)
patch 8.2.4510: Vim9: shortening commands leads to confusing scriptv8.2.4510
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".
Diffstat (limited to 'src/ex_docmd.c')
-rw-r--r--src/ex_docmd.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/src/ex_docmd.c b/src/ex_docmd.c
index 287045bc5d..6b2bdd4e5c 100644
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -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