summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-08-02 20:40:43 +0200
committerBram Moolenaar <Bram@vim.org>2020-08-02 20:40:43 +0200
commit83144546488b544a1fe4e2a4f8be954b98c696fc (patch)
tree16bd66c688611b0e812405fb2d98e43ee2e70bd8
parent434d72cbf2170d54cb4f8acbe995a9a55cceb92a (diff)
downloadvim-git-83144546488b544a1fe4e2a4f8be954b98c696fc.tar.gz
patch 8.2.1359: Vim9: cannot assign to / register in Vim9 scriptv8.2.1359
Problem: Vim9: cannot assign to / register in Vim9 script. Solution: Adjust check for assignment in Vim9 script. (closes #6567)
-rw-r--r--src/ex_docmd.c8
-rw-r--r--src/testdir/test_vim9_script.vim17
-rw-r--r--src/version.c2
3 files changed, 24 insertions, 3 deletions
diff --git a/src/ex_docmd.c b/src/ex_docmd.c
index 185fc49cb..105710b01 100644
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -3274,10 +3274,10 @@ find_ex_command(
if (lookup != NULL)
{
// Skip over first char for "&opt = val", "$ENV = val" and "@r = val".
- char_u *pskip = (*eap->cmd == '&' || *eap->cmd == '$'
- || *eap->cmd == '@') ? eap->cmd + 1 : eap->cmd;
+ char_u *pskip = (*eap->cmd == '&' || *eap->cmd == '$')
+ ? eap->cmd + 1 : 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;
@@ -3336,6 +3336,8 @@ find_ex_command(
// Recognize an assignment if we recognize the variable name:
// "g:var = expr"
// "var = expr" where "var" is a local var name.
+ if (*eap->cmd == '@')
+ p = eap->cmd + 2;
oplen = assignment_len(skipwhite(p), &heredoc);
if (oplen > 0)
{
diff --git a/src/testdir/test_vim9_script.vim b/src/testdir/test_vim9_script.vim
index f359a9d91..64ac3bbd9 100644
--- a/src/testdir/test_vim9_script.vim
+++ b/src/testdir/test_vim9_script.vim
@@ -423,6 +423,23 @@ def Test_assignment_vim9script()
let ll =
Func()
assert_equal([1, 2], ll)
+
+ @/ = 'text'
+ assert_equal('text', @/)
+ @0 = 'zero'
+ assert_equal('zero', @0)
+ @1 = 'one'
+ assert_equal('one', @1)
+ @9 = 'nine'
+ assert_equal('nine', @9)
+ @- = 'minus'
+ assert_equal('minus', @-)
+ if has('clipboard_working')
+ @* = 'star'
+ assert_equal('star', @*)
+ @+ = 'plus'
+ assert_equal('plus', @+)
+ endif
END
CheckScriptSuccess(lines)
enddef
diff --git a/src/version.c b/src/version.c
index 4f1d8a179..c169daf8d 100644
--- a/src/version.c
+++ b/src/version.c
@@ -755,6 +755,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1359,
+/**/
1358,
/**/
1357,