diff options
author | Bram Moolenaar <Bram@vim.org> | 2021-02-02 21:33:52 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-02-02 21:33:52 +0100 |
commit | 148be9bc1cca16ce47ad21563f5835682001f9a2 (patch) | |
tree | 6a677b39b0ea5e785562ce51bbb7fc08a7893d94 | |
parent | d5e8c92816f35ea1a9298084238a08f35958baa6 (diff) | |
download | vim-git-148be9bc1cca16ce47ad21563f5835682001f9a2.tar.gz |
patch 8.2.2453: Vim9: a variable name with "->" in the next line doesn't workv8.2.2453
Problem: Vim9: a variable name with "->" in the next line doesn't work.
Solution: Recognize a variable name by itself. (closes #7770)
-rw-r--r-- | src/ex_docmd.c | 10 | ||||
-rw-r--r-- | src/testdir/test_vim9_cmd.vim | 23 | ||||
-rw-r--r-- | src/version.c | 2 |
3 files changed, 35 insertions, 0 deletions
diff --git a/src/ex_docmd.c b/src/ex_docmd.c index 8b9db6812..d31b56c8c 100644 --- a/src/ex_docmd.c +++ b/src/ex_docmd.c @@ -3424,6 +3424,16 @@ find_ex_command( return eap->cmd; } } + + // If it is an ID it might be a variable with an operator on the next + // line, if the variable exists it can't be an Ex command. + if (p > eap->cmd && ends_excmd(*skipwhite(p)) + && (lookup(eap->cmd, p - eap->cmd, NULL, cctx) == OK + || (ASCII_ISALPHA(eap->cmd[0]) && eap->cmd[1] == ':'))) + { + eap->cmdidx = CMD_eval; + return eap->cmd; + } } #endif diff --git a/src/testdir/test_vim9_cmd.vim b/src/testdir/test_vim9_cmd.vim index 2f8fd71e9..ef0a5fe2e 100644 --- a/src/testdir/test_vim9_cmd.vim +++ b/src/testdir/test_vim9_cmd.vim @@ -328,6 +328,29 @@ def Test_method_call_linebreak() assert_equal([1, 2, 3], res) END CheckScriptSuccess(lines) + + lines =<< trim END + new + var name = [1, 2] + name + ->copy() + ->setline(1) + assert_equal(['1', '2'], getline(1, 2)) + bwipe! + END + CheckDefAndScriptSuccess(lines) + + lines =<< trim END + new + g:shortlist + ->copy() + ->setline(1) + assert_equal(['1', '2'], getline(1, 2)) + bwipe! + END + g:shortlist = [1, 2] + CheckDefAndScriptSuccess(lines) + unlet g:shortlist enddef def Test_method_call_whitespace() diff --git a/src/version.c b/src/version.c index c5f21db2c..679f3a57e 100644 --- a/src/version.c +++ b/src/version.c @@ -751,6 +751,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 2453, +/**/ 2452, /**/ 2451, |