mirror of
https://github.com/vim/vim.git
synced 2025-09-24 03:44:06 -04:00
patch 8.2.2888: Vim9: "k" command recognized in Vim9 script
Problem: Vim9: "k" command recognized in Vim9 script. Solution: Do not recognize "k" or "s" and "d" with flags.
This commit is contained in:
@@ -3392,8 +3392,11 @@ find_ex_command(
|
|||||||
int len;
|
int len;
|
||||||
char_u *p;
|
char_u *p;
|
||||||
int i;
|
int i;
|
||||||
|
#ifndef FEAT_EVAL
|
||||||
|
int vim9 = FALSE;
|
||||||
|
#else
|
||||||
|
int vim9 = in_vim9script();
|
||||||
|
|
||||||
#ifdef FEAT_EVAL
|
|
||||||
/*
|
/*
|
||||||
* Recognize a Vim9 script function/method call and assignment:
|
* Recognize a Vim9 script function/method call and assignment:
|
||||||
* "lvar = value", "lvar(arg)", "[1, 2 3]->Func()"
|
* "lvar = value", "lvar(arg)", "[1, 2 3]->Func()"
|
||||||
@@ -3556,12 +3559,13 @@ find_ex_command(
|
|||||||
* - the "d" command can directly be followed by 'l' or 'p' flag.
|
* - the "d" command can directly be followed by 'l' or 'p' flag.
|
||||||
*/
|
*/
|
||||||
p = eap->cmd;
|
p = eap->cmd;
|
||||||
if (*p == 'k')
|
if (!vim9 && *p == 'k')
|
||||||
{
|
{
|
||||||
eap->cmdidx = CMD_k;
|
eap->cmdidx = CMD_k;
|
||||||
++p;
|
++p;
|
||||||
}
|
}
|
||||||
else if (p[0] == 's'
|
else if (!vim9
|
||||||
|
&& p[0] == 's'
|
||||||
&& ((p[1] == 'c' && (p[2] == NUL || (p[2] != 's' && p[2] != 'r'
|
&& ((p[1] == 'c' && (p[2] == NUL || (p[2] != 's' && p[2] != 'r'
|
||||||
&& (p[3] == NUL || (p[3] != 'i' && p[4] != 'p')))))
|
&& (p[3] == NUL || (p[3] != 'i' && p[4] != 'p')))))
|
||||||
|| p[1] == 'g'
|
|| p[1] == 'g'
|
||||||
@@ -3594,7 +3598,7 @@ find_ex_command(
|
|||||||
if (p == eap->cmd && vim_strchr((char_u *)"@*!=><&~#}", *p) != NULL)
|
if (p == eap->cmd && vim_strchr((char_u *)"@*!=><&~#}", *p) != NULL)
|
||||||
++p;
|
++p;
|
||||||
len = (int)(p - eap->cmd);
|
len = (int)(p - eap->cmd);
|
||||||
if (*eap->cmd == 'd' && (p[-1] == 'l' || p[-1] == 'p'))
|
if (!vim9 && *eap->cmd == 'd' && (p[-1] == 'l' || p[-1] == 'p'))
|
||||||
{
|
{
|
||||||
// Check for ":dl", ":dell", etc. to ":deletel": that's
|
// Check for ":dl", ":dell", etc. to ":deletel": that's
|
||||||
// :delete with the 'l' flag. Same for 'p'.
|
// :delete with the 'l' flag. Same for 'p'.
|
||||||
@@ -3671,7 +3675,7 @@ find_ex_command(
|
|||||||
|
|
||||||
#ifdef FEAT_EVAL
|
#ifdef FEAT_EVAL
|
||||||
if (eap->cmdidx < CMD_SIZE
|
if (eap->cmdidx < CMD_SIZE
|
||||||
&& in_vim9script()
|
&& vim9
|
||||||
&& !IS_WHITE_OR_NUL(*p) && *p != '\n' && *p != '!'
|
&& !IS_WHITE_OR_NUL(*p) && *p != '\n' && *p != '!'
|
||||||
&& (eap->cmdidx < 0 ||
|
&& (eap->cmdidx < 0 ||
|
||||||
(cmdnames[eap->cmdidx].cmd_argt & EX_NONWHITE_OK) == 0))
|
(cmdnames[eap->cmdidx].cmd_argt & EX_NONWHITE_OK) == 0))
|
||||||
@@ -3802,9 +3806,21 @@ f_fullcommand(typval_T *argvars, typval_T *rettv)
|
|||||||
|
|
||||||
ea.cmd = (*name == '2' || *name == '3') ? name + 1 : name;
|
ea.cmd = (*name == '2' || *name == '3') ? name + 1 : name;
|
||||||
ea.cmdidx = (cmdidx_T)0;
|
ea.cmdidx = (cmdidx_T)0;
|
||||||
|
ea.addr_count = 0;
|
||||||
p = find_ex_command(&ea, NULL, NULL, NULL);
|
p = find_ex_command(&ea, NULL, NULL, NULL);
|
||||||
if (p == NULL || ea.cmdidx == CMD_SIZE)
|
if (p == NULL || ea.cmdidx == CMD_SIZE)
|
||||||
return;
|
return;
|
||||||
|
if (in_vim9script())
|
||||||
|
{
|
||||||
|
int res;
|
||||||
|
|
||||||
|
++emsg_silent;
|
||||||
|
res = not_in_vim9(&ea);
|
||||||
|
--emsg_silent;
|
||||||
|
|
||||||
|
if (res == FAIL)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
rettv->vval.v_string = vim_strsave(IS_USER_CMDIDX(ea.cmdidx)
|
rettv->vval.v_string = vim_strsave(IS_USER_CMDIDX(ea.cmdidx)
|
||||||
? get_user_commands(NULL, ea.useridx)
|
? get_user_commands(NULL, ea.useridx)
|
||||||
|
@@ -554,6 +554,29 @@ def Test_filter_missing_argument()
|
|||||||
res->assert_equal({aa: [1], ac: [3]})
|
res->assert_equal({aa: [1], ac: [3]})
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
|
def Test_fullcommand()
|
||||||
|
assert_equal('next', fullcommand('n'))
|
||||||
|
assert_equal('noremap', fullcommand('no'))
|
||||||
|
assert_equal('noremap', fullcommand('nor'))
|
||||||
|
assert_equal('normal', fullcommand('norm'))
|
||||||
|
|
||||||
|
assert_equal('', fullcommand('k'))
|
||||||
|
assert_equal('keepmarks', fullcommand('ke'))
|
||||||
|
assert_equal('keepmarks', fullcommand('kee'))
|
||||||
|
assert_equal('keepmarks', fullcommand('keep'))
|
||||||
|
assert_equal('keepjumps', fullcommand('keepj'))
|
||||||
|
|
||||||
|
assert_equal('dlist', fullcommand('dl'))
|
||||||
|
assert_equal('', fullcommand('dp'))
|
||||||
|
assert_equal('delete', fullcommand('del'))
|
||||||
|
assert_equal('', fullcommand('dell'))
|
||||||
|
assert_equal('', fullcommand('delp'))
|
||||||
|
|
||||||
|
assert_equal('srewind', fullcommand('sre'))
|
||||||
|
assert_equal('scriptnames', fullcommand('scr'))
|
||||||
|
assert_equal('', fullcommand('scg'))
|
||||||
|
enddef
|
||||||
|
|
||||||
def Test_garbagecollect()
|
def Test_garbagecollect()
|
||||||
garbagecollect(true)
|
garbagecollect(true)
|
||||||
enddef
|
enddef
|
||||||
|
@@ -3844,12 +3844,14 @@ def Test_unsupported_commands()
|
|||||||
var lines =<< trim END
|
var lines =<< trim END
|
||||||
ka
|
ka
|
||||||
END
|
END
|
||||||
CheckDefAndScriptFailure(lines, 'E1100:')
|
CheckDefFailure(lines, 'E476:')
|
||||||
|
CheckScriptFailure(['vim9script'] + lines, 'E492:')
|
||||||
|
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
:1ka
|
:1ka
|
||||||
END
|
END
|
||||||
CheckDefAndScriptFailure(lines, 'E481:')
|
CheckDefFailure(lines, 'E476:')
|
||||||
|
CheckScriptFailure(['vim9script'] + lines, 'E492:')
|
||||||
|
|
||||||
lines =<< trim END
|
lines =<< trim END
|
||||||
t
|
t
|
||||||
|
@@ -750,6 +750,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 */
|
||||||
|
/**/
|
||||||
|
2888,
|
||||||
/**/
|
/**/
|
||||||
2887,
|
2887,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user