diff options
author | Bram Moolenaar <Bram@vim.org> | 2021-02-19 21:42:57 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-02-19 21:42:57 +0100 |
commit | 10b9421f3bb7ac971fa63bd025c4c603c98f4a49 (patch) | |
tree | d0e41baa8a966d3071f2ddcb6a142d837547b6dc /src | |
parent | 12d265315fac9e4f3436c38a87f6d9a23b9e7e2b (diff) |
patch 8.2.2531: Vim9: the :k command is obscurev8.2.2531
Problem: Vim9: the :k command is obscure.
Solution: Disallow using :k, can use :mark instead. (closes #7874)
Diffstat (limited to 'src')
-rw-r--r-- | src/ex_cmds.h | 2 | ||||
-rw-r--r-- | src/ex_docmd.c | 7 | ||||
-rw-r--r-- | src/testdir/test_vim9_script.vim | 25 | ||||
-rw-r--r-- | src/version.c | 2 | ||||
-rw-r--r-- | src/vim9compile.c | 1 | ||||
-rw-r--r-- | src/vim9script.c | 1 |
6 files changed, 36 insertions, 2 deletions
diff --git a/src/ex_cmds.h b/src/ex_cmds.h index e82e91bb37..7888d6fee0 100644 --- a/src/ex_cmds.h +++ b/src/ex_cmds.h @@ -741,7 +741,7 @@ EXCMD(CMD_jumps, "jumps", ex_jumps, EX_TRLBAR|EX_CMDWIN|EX_LOCK_OK, ADDR_NONE), EXCMD(CMD_k, "k", ex_mark, - EX_RANGE|EX_WORD1|EX_TRLBAR|EX_SBOXOK|EX_CMDWIN|EX_LOCK_OK, + EX_RANGE|EX_WORD1|EX_TRLBAR|EX_SBOXOK|EX_CMDWIN|EX_LOCK_OK|EX_NONWHITE_OK, ADDR_LINES), EXCMD(CMD_keepmarks, "keepmarks", ex_wrongmodifier, EX_NEEDARG|EX_EXTRA|EX_NOTRLCOM, diff --git a/src/ex_docmd.c b/src/ex_docmd.c index 371f3d6062..77162ec7d6 100644 --- a/src/ex_docmd.c +++ b/src/ex_docmd.c @@ -3461,7 +3461,8 @@ find_ex_command( /* * Isolate the command and search for it in the command table. * Exceptions: - * - the 'k' command can directly be followed by any character. + * - The 'k' command can directly be followed by any character. + * But it is not used in Vim9 script. * - the 's' command can be followed directly by 'c', 'g', 'i', 'I' or 'r' * but :sre[wind] is another command, as are :scr[iptnames], * :scs[cope], :sim[alt], :sig[ns] and :sil[ent]. @@ -8056,6 +8057,10 @@ ex_mark(exarg_T *eap) { pos_T pos; +#ifdef FEAT_EVAL + if (not_in_vim9(eap) == FAIL) + return; +#endif if (*eap->arg == NUL) // No argument? emsg(_(e_argreq)); else if (eap->arg[1] != NUL) // more than one character? diff --git a/src/testdir/test_vim9_script.vim b/src/testdir/test_vim9_script.vim index f444bb5a8d..d22c6538b8 100644 --- a/src/testdir/test_vim9_script.vim +++ b/src/testdir/test_vim9_script.vim @@ -3491,6 +3491,31 @@ def Test_import_gone_when_sourced_twice() unlet g:guard enddef +def Test_unsupported_commands() + var lines =<< trim END + ka + END + CheckDefAndScriptFailure(lines, 'E1100:') + + lines =<< trim END + t + END + CheckDefFailure(lines, 'E1100:') + CheckScriptFailure(['vim9script'] + lines, 'E1100:') + + lines =<< trim END + x + END + CheckDefFailure(lines, 'E1100:') + CheckScriptFailure(['vim9script'] + lines, 'E1100:') + + lines =<< trim END + xit + END + CheckDefFailure(lines, 'E1100:') + CheckScriptFailure(['vim9script'] + lines, 'E1100:') +enddef + " Keep this last, it messes up highlighting. def Test_substitute_cmd() new diff --git a/src/version.c b/src/version.c index 7e42fa3abb..d802a49c28 100644 --- a/src/version.c +++ b/src/version.c @@ -751,6 +751,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 2531, +/**/ 2530, /**/ 2529, diff --git a/src/vim9compile.c b/src/vim9compile.c index 84c9108cac..c75ead9d95 100644 --- a/src/vim9compile.c +++ b/src/vim9compile.c @@ -8520,6 +8520,7 @@ compile_def_function( case CMD_append: case CMD_change: case CMD_insert: + case CMD_k: case CMD_t: case CMD_xit: not_in_vim9(&ea); diff --git a/src/vim9script.c b/src/vim9script.c index d40104cb7a..751d8fb770 100644 --- a/src/vim9script.c +++ b/src/vim9script.c @@ -95,6 +95,7 @@ not_in_vim9(exarg_T *eap) case CMD_append: case CMD_change: case CMD_insert: + case CMD_k: case CMD_t: case CMD_xit: semsg(_(e_command_not_supported_in_vim9_script_missing_var_str), eap->cmd); |