Mercurial > vim
changeset 21618:9ab43576a13b v8.2.1359
patch 8.2.1359: Vim9: cannot assign to / register in Vim9 script
Commit: https://github.com/vim/vim/commit/83144546488b544a1fe4e2a4f8be954b98c696fc
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Aug 2 20:40:43 2020 +0200
patch 8.2.1359: Vim9: cannot assign to / register in Vim9 script
Problem: Vim9: cannot assign to / register in Vim9 script.
Solution: Adjust check for assignment in Vim9 script. (closes https://github.com/vim/vim/issues/6567)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 02 Aug 2020 20:45:04 +0200 |
parents | 74a20165daaf |
children | aae35544194c |
files | src/ex_docmd.c src/testdir/test_vim9_script.vim src/version.c |
diffstat | 3 files changed, 25 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- 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; - - if (vim_strchr((char_u *)"{('[\"", *p) != NULL + char_u *pskip = (*eap->cmd == '&' || *eap->cmd == '$') + ? eap->cmd + 1 : eap->cmd; + + 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) {
--- 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