summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2021-08-24 21:56:03 +0200
committerBram Moolenaar <Bram@vim.org>2021-08-24 21:56:03 +0200
commit5ca5cc6412d7d68fd380926f9551a8b7ba335199 (patch)
tree8f45b217f46ee530fe145ec9912305cc4aa6d165
parent60faf8656e1a100778bf7cd4d305380fb852d540 (diff)
patch 8.2.3371: Vim9: :$ENV cannot be followed by ->func() in next linev8.2.3371
Problem: Vim9: :$ENV cannot be followed by ->func() in next line. Solution: Use "$ENV" as the start of an expression. (closes #8790)
-rw-r--r--src/ex_docmd.c12
-rw-r--r--src/testdir/test_vim9_cmd.vim16
-rw-r--r--src/version.c2
-rw-r--r--src/vim9compile.c2
4 files changed, 28 insertions, 4 deletions
diff --git a/src/ex_docmd.c b/src/ex_docmd.c
index 85df6cdc27..58980738f2 100644
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -3425,14 +3425,16 @@ find_ex_command(
{
char_u *pskip = skip_option_env_lead(eap->cmd);
- if (vim_strchr((char_u *)"{('[\"@&", *p) != NULL
+ if (vim_strchr((char_u *)"{('[\"@&$", *p) != NULL
|| ((p = to_name_const_end(pskip)) > eap->cmd && *p != NUL))
{
int oplen;
int heredoc;
char_u *swp;
- if (*eap->cmd == '&' || (eap->cmd[0] == '@'
+ if (*eap->cmd == '&'
+ || *eap->cmd == '$'
+ || (eap->cmd[0] == '@'
&& (valid_yank_reg(eap->cmd[1], FALSE)
|| eap->cmd[1] == '@')))
{
@@ -3443,12 +3445,14 @@ find_ex_command(
p += 2;
p = to_name_end(p, FALSE);
}
+ else if (*eap->cmd == '$')
+ p = to_name_end(eap->cmd + 1, FALSE);
else
p = eap->cmd + 2;
if (ends_excmd(*skipwhite(p)))
{
- // "&option <NL>" and "@r <NL>" is the start of an
- // expression.
+ // "&option <NL>", "$ENV <NL>" and "@r <NL>" are the start
+ // of an expression.
eap->cmdidx = CMD_eval;
return eap->cmd;
}
diff --git a/src/testdir/test_vim9_cmd.vim b/src/testdir/test_vim9_cmd.vim
index ec845ea40b..128575b955 100644
--- a/src/testdir/test_vim9_cmd.vim
+++ b/src/testdir/test_vim9_cmd.vim
@@ -553,6 +553,22 @@ def Test_register_use_linebreak()
CheckDefAndScriptSuccess(lines)
enddef
+def Test_environment_use_linebreak()
+ var lines =<< trim END
+ new
+ $TESTENV = 'one'
+ $TESTENV->setline(1)
+ $TESTENV = 'two'
+ $TESTENV ->setline(2)
+ $TESTENV = 'three'
+ $TESTENV
+ ->setline(3)
+ assert_equal(['one', 'two', 'three'], getline(1, '$'))
+ bwipe!
+ END
+ CheckDefAndScriptSuccess(lines)
+enddef
+
def Test_skipped_expr_linebreak()
if 0
var x = []
diff --git a/src/version.c b/src/version.c
index c5142d277b..6e7dd93cbf 100644
--- a/src/version.c
+++ b/src/version.c
@@ -756,6 +756,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 3371,
+/**/
3370,
/**/
3369,
diff --git a/src/vim9compile.c b/src/vim9compile.c
index 90e6bf2677..97bd292bba 100644
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -9745,9 +9745,11 @@ compile_def_function(
* COMMAND after range
* 'text'->func() should not be confused with 'a mark
* "++nr" and "--nr" are eval commands
+ * in "$ENV->func()" the "$" is not a range
*/
cmd = ea.cmd;
if (!(local_cmdmod.cmod_flags & CMOD_LEGACY)
+ && (*cmd != '$' || starts_with_colon)
&& (starts_with_colon || !(*cmd == '\''
|| (cmd[0] == cmd[1] && (*cmd == '+' || *cmd == '-')))))
{