mirror of
https://github.com/vim/vim.git
synced 2025-07-26 11:04:33 -04:00
patch 9.0.0637: syntax of commands in Vim9 script depends on +eval feature
Problem: Syntax of commands in Vim9 script depends on +eval feature. Solution: Use same syntax with and without the +eval feature.
This commit is contained in:
parent
b393275ae9
commit
eda29c971c
@ -2713,8 +2713,10 @@ EXTERN char e_item_not_found_in_script_str[]
|
|||||||
INIT(= N_("E1048: Item not found in script: %s"));
|
INIT(= N_("E1048: Item not found in script: %s"));
|
||||||
EXTERN char e_item_not_exported_in_script_str[]
|
EXTERN char e_item_not_exported_in_script_str[]
|
||||||
INIT(= N_("E1049: Item not exported in script: %s"));
|
INIT(= N_("E1049: Item not exported in script: %s"));
|
||||||
|
#endif
|
||||||
EXTERN char e_colon_required_before_range_str[]
|
EXTERN char e_colon_required_before_range_str[]
|
||||||
INIT(= N_("E1050: Colon required before a range: %s"));
|
INIT(= N_("E1050: Colon required before a range: %s"));
|
||||||
|
#ifdef FEAT_EVAL
|
||||||
EXTERN char e_wrong_argument_type_for_plus[]
|
EXTERN char e_wrong_argument_type_for_plus[]
|
||||||
INIT(= N_("E1051: Wrong argument type for +"));
|
INIT(= N_("E1051: Wrong argument type for +"));
|
||||||
EXTERN char e_cannot_declare_an_option[]
|
EXTERN char e_cannot_declare_an_option[]
|
||||||
|
@ -1684,10 +1684,8 @@ current_tab_nr(tabpage_T *tab)
|
|||||||
static int
|
static int
|
||||||
comment_start(char_u *p, int starts_with_colon UNUSED)
|
comment_start(char_u *p, int starts_with_colon UNUSED)
|
||||||
{
|
{
|
||||||
#ifdef FEAT_EVAL
|
|
||||||
if (in_vim9script())
|
if (in_vim9script())
|
||||||
return p[0] == '#' && !starts_with_colon;
|
return p[0] == '#' && !starts_with_colon;
|
||||||
#endif
|
|
||||||
return *p == '"';
|
return *p == '"';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1736,9 +1734,9 @@ do_one_cmd(
|
|||||||
int ni; // set when Not Implemented
|
int ni; // set when Not Implemented
|
||||||
char_u *cmd;
|
char_u *cmd;
|
||||||
int starts_with_colon = FALSE;
|
int starts_with_colon = FALSE;
|
||||||
#ifdef FEAT_EVAL
|
|
||||||
int may_have_range;
|
int may_have_range;
|
||||||
int vim9script;
|
int vim9script;
|
||||||
|
#ifdef FEAT_EVAL
|
||||||
int did_set_expr_line = FALSE;
|
int did_set_expr_line = FALSE;
|
||||||
#endif
|
#endif
|
||||||
int sourcing = flags & DOCMD_VERBOSE;
|
int sourcing = flags & DOCMD_VERBOSE;
|
||||||
@ -1787,9 +1785,6 @@ do_one_cmd(
|
|||||||
if (parse_command_modifiers(&ea, &errormsg, &cmdmod, FALSE) == FAIL)
|
if (parse_command_modifiers(&ea, &errormsg, &cmdmod, FALSE) == FAIL)
|
||||||
goto doend;
|
goto doend;
|
||||||
apply_cmdmod(&cmdmod);
|
apply_cmdmod(&cmdmod);
|
||||||
#ifdef FEAT_EVAL
|
|
||||||
vim9script = in_vim9script();
|
|
||||||
#endif
|
|
||||||
after_modifier = ea.cmd;
|
after_modifier = ea.cmd;
|
||||||
|
|
||||||
#ifdef FEAT_EVAL
|
#ifdef FEAT_EVAL
|
||||||
@ -1805,9 +1800,10 @@ do_one_cmd(
|
|||||||
* We need the command to know what kind of range it uses.
|
* We need the command to know what kind of range it uses.
|
||||||
*/
|
*/
|
||||||
cmd = ea.cmd;
|
cmd = ea.cmd;
|
||||||
#ifdef FEAT_EVAL
|
|
||||||
// In Vim9 script a colon is required before the range. This may also be
|
// In Vim9 script a colon is required before the range. This may also be
|
||||||
// after command modifiers.
|
// after command modifiers.
|
||||||
|
vim9script = in_vim9script();
|
||||||
if (vim9script && (flags & DOCMD_RANGEOK) == 0)
|
if (vim9script && (flags & DOCMD_RANGEOK) == 0)
|
||||||
{
|
{
|
||||||
may_have_range = FALSE;
|
may_have_range = FALSE;
|
||||||
@ -1822,16 +1818,18 @@ do_one_cmd(
|
|||||||
else
|
else
|
||||||
may_have_range = TRUE;
|
may_have_range = TRUE;
|
||||||
if (may_have_range)
|
if (may_have_range)
|
||||||
#endif
|
|
||||||
ea.cmd = skip_range(ea.cmd, TRUE, NULL);
|
ea.cmd = skip_range(ea.cmd, TRUE, NULL);
|
||||||
|
|
||||||
#ifdef FEAT_EVAL
|
|
||||||
if (vim9script && !may_have_range)
|
if (vim9script && !may_have_range)
|
||||||
{
|
{
|
||||||
if (ea.cmd == cmd + 1 && *cmd == '$')
|
if (ea.cmd == cmd + 1 && *cmd == '$')
|
||||||
// should be "$VAR = val"
|
// should be "$VAR = val"
|
||||||
--ea.cmd;
|
--ea.cmd;
|
||||||
|
#ifdef FEAT_EVAL
|
||||||
p = find_ex_command(&ea, NULL, lookup_scriptitem, NULL);
|
p = find_ex_command(&ea, NULL, lookup_scriptitem, NULL);
|
||||||
|
#else
|
||||||
|
p = find_ex_command(&ea, NULL, NULL, NULL);
|
||||||
|
#endif
|
||||||
if (ea.cmdidx == CMD_SIZE)
|
if (ea.cmdidx == CMD_SIZE)
|
||||||
{
|
{
|
||||||
char_u *ar = skip_range(ea.cmd, TRUE, NULL);
|
char_u *ar = skip_range(ea.cmd, TRUE, NULL);
|
||||||
@ -1846,7 +1844,6 @@ do_one_cmd(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
|
||||||
p = find_ex_command(&ea, NULL, NULL, NULL);
|
p = find_ex_command(&ea, NULL, NULL, NULL);
|
||||||
|
|
||||||
#ifdef FEAT_EVAL
|
#ifdef FEAT_EVAL
|
||||||
@ -1930,13 +1927,10 @@ do_one_cmd(
|
|||||||
}
|
}
|
||||||
|
|
||||||
ea.cmd = cmd;
|
ea.cmd = cmd;
|
||||||
#ifdef FEAT_EVAL
|
|
||||||
if (!may_have_range)
|
if (!may_have_range)
|
||||||
ea.line1 = ea.line2 = default_address(&ea);
|
ea.line1 = ea.line2 = default_address(&ea);
|
||||||
else
|
else if (parse_cmd_address(&ea, &errormsg, FALSE) == FAIL)
|
||||||
#endif
|
goto doend;
|
||||||
if (parse_cmd_address(&ea, &errormsg, FALSE) == FAIL)
|
|
||||||
goto doend;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 5. Parse the command.
|
* 5. Parse the command.
|
||||||
@ -5275,24 +5269,20 @@ separate_nextcmd(exarg_T *eap, int keep_backslash)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Check for '"': start of comment or '|': next command
|
// Check for '"'/'#': start of comment or '|': next command
|
||||||
// :@" and :*" do not start a comment!
|
// :@" and :*" do not start a comment!
|
||||||
// :redir @" doesn't either.
|
// :redir @" doesn't either.
|
||||||
else if ((*p == '"'
|
else if ((*p == '"'
|
||||||
#ifdef FEAT_EVAL
|
|
||||||
&& !in_vim9script()
|
&& !in_vim9script()
|
||||||
#endif
|
|
||||||
&& !(eap->argt & EX_NOTRLCOM)
|
&& !(eap->argt & EX_NOTRLCOM)
|
||||||
&& ((eap->cmdidx != CMD_at && eap->cmdidx != CMD_star)
|
&& ((eap->cmdidx != CMD_at && eap->cmdidx != CMD_star)
|
||||||
|| p != eap->arg)
|
|| p != eap->arg)
|
||||||
&& (eap->cmdidx != CMD_redir
|
&& (eap->cmdidx != CMD_redir
|
||||||
|| p != eap->arg + 1 || p[-1] != '@'))
|
|| p != eap->arg + 1 || p[-1] != '@'))
|
||||||
#ifdef FEAT_EVAL
|
|
||||||
|| (*p == '#'
|
|| (*p == '#'
|
||||||
&& in_vim9script()
|
&& in_vim9script()
|
||||||
&& !(eap->argt & EX_NOTRLCOM)
|
&& !(eap->argt & EX_NOTRLCOM)
|
||||||
&& p > eap->cmd && VIM_ISWHITE(p[-1]))
|
&& p > eap->cmd && VIM_ISWHITE(p[-1]))
|
||||||
#endif
|
|
||||||
|| *p == '|' || *p == '\n')
|
|| *p == '|' || *p == '\n')
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
@ -5636,10 +5626,8 @@ ends_excmd(int c)
|
|||||||
{
|
{
|
||||||
int comment_char = '"';
|
int comment_char = '"';
|
||||||
|
|
||||||
#ifdef FEAT_EVAL
|
|
||||||
if (in_vim9script())
|
if (in_vim9script())
|
||||||
comment_char = '#';
|
comment_char = '#';
|
||||||
#endif
|
|
||||||
return (c == NUL || c == '|' || c == comment_char || c == '\n');
|
return (c == NUL || c == '|' || c == comment_char || c == '\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5654,12 +5642,10 @@ ends_excmd2(char_u *cmd_start UNUSED, char_u *cmd)
|
|||||||
|
|
||||||
if (c == NUL || c == '|' || c == '\n')
|
if (c == NUL || c == '|' || c == '\n')
|
||||||
return TRUE;
|
return TRUE;
|
||||||
#ifdef FEAT_EVAL
|
|
||||||
if (in_vim9script())
|
if (in_vim9script())
|
||||||
// # starts a comment, #{ might be a mistake, #{{ can start a fold
|
// # starts a comment, #{ might be a mistake, #{{ can start a fold
|
||||||
return c == '#' && (cmd[1] != '{' || cmd[2] == '{')
|
return c == '#' && (cmd[1] != '{' || cmd[2] == '{')
|
||||||
&& (cmd == cmd_start || VIM_ISWHITE(cmd[-1]));
|
&& (cmd == cmd_start || VIM_ISWHITE(cmd[-1]));
|
||||||
#endif
|
|
||||||
return c == '"';
|
return c == '"';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@ CLEANUP_FILES = test.log messages starttime
|
|||||||
|
|
||||||
# Tests for tiny and small builds.
|
# Tests for tiny and small builds.
|
||||||
SCRIPTS_TINY = \
|
SCRIPTS_TINY = \
|
||||||
|
test10 \
|
||||||
test20 \
|
test20 \
|
||||||
test21 \
|
test21 \
|
||||||
test22 \
|
test22 \
|
||||||
@ -22,6 +23,7 @@ SCRIPTS_TINY = \
|
|||||||
test27
|
test27
|
||||||
|
|
||||||
SCRIPTS_TINY_OUT = \
|
SCRIPTS_TINY_OUT = \
|
||||||
|
test10.out \
|
||||||
test20.out \
|
test20.out \
|
||||||
test21.out \
|
test21.out \
|
||||||
test22.out \
|
test22.out \
|
||||||
|
21
src/testdir/test10.in
Normal file
21
src/testdir/test10.in
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
Test that vim9script also works without the +eval feature.
|
||||||
|
|
||||||
|
STARTTEST
|
||||||
|
:/^START/+1,/^END/-1:w! Xvim9
|
||||||
|
:so Xvim9
|
||||||
|
ENDTEST
|
||||||
|
|
||||||
|
START
|
||||||
|
vim9script
|
||||||
|
|
||||||
|
if 1
|
||||||
|
echo 'this is skipped without +eval'
|
||||||
|
endif
|
||||||
|
|
||||||
|
# colon required for a range
|
||||||
|
:$-1,$w! test.out
|
||||||
|
qa!
|
||||||
|
END
|
||||||
|
|
||||||
|
first line
|
||||||
|
last line
|
2
src/testdir/test10.ok
Normal file
2
src/testdir/test10.ok
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
first line
|
||||||
|
last line
|
@ -699,6 +699,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 */
|
||||||
|
/**/
|
||||||
|
637,
|
||||||
/**/
|
/**/
|
||||||
636,
|
636,
|
||||||
/**/
|
/**/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user