# HG changeset patch # User Bram Moolenaar # Date 1629665103 -7200 # Node ID 23f065f27d2e33d0cf7bf28e2f56a7586a675462 # Parent cb69ba1652c6b8c049e9839e16fe0fcb03b3460c patch 8.2.3367: Vim9: :@r executing a register is inconsistent Commit: https://github.com/vim/vim/commit/73170917f14d1b0d919c65fbc0a9d011b87d94da Author: Bram Moolenaar Date: Sun Aug 22 22:44:11 2021 +0200 patch 8.2.3367: Vim9: :@r executing a register is inconsistent Problem: Vim9: :@r executing a register is inconsistent. Solution: Use "@r" as the start of an expression. (issue https://github.com/vim/vim/issues/8779) diff --git a/src/ex_docmd.c b/src/ex_docmd.c --- a/src/ex_docmd.c +++ b/src/ex_docmd.c @@ -3432,12 +3432,23 @@ find_ex_command( int heredoc; char_u *swp; - if (*eap->cmd == '&') + if (*eap->cmd == '&' || (eap->cmd[0] == '@' + && (valid_yank_reg(eap->cmd[1], FALSE) + || eap->cmd[1] == '@'))) { - p = to_name_end(eap->cmd + 1, FALSE); + if (*eap->cmd == '&') + { + p = eap->cmd + 1; + if (STRNCMP("l:", p, 2) == 0 || STRNCMP("g:", p, 2) == 0) + p += 2; + p = to_name_end(p, FALSE); + } + else + p = eap->cmd + 2; if (ends_excmd(*skipwhite(p))) { - // "&option " is the start of an expression. + // "&option " and "@r " is the start of an + // expression. eap->cmdidx = CMD_eval; return eap->cmd; } @@ -3548,10 +3559,6 @@ find_ex_command( // "&opt = expr" // "var = expr" where "var" is a variable name or we are skipping // (variable declaration might have been skipped). - if (*eap->cmd == '@') - p = eap->cmd + 2; - else if (*eap->cmd == '&') - p = skiptowhite_esc(eap->cmd + 1); oplen = assignment_len(skipwhite(p), &heredoc); if (oplen > 0) { diff --git a/src/testdir/test_vim9_cmd.vim b/src/testdir/test_vim9_cmd.vim --- a/src/testdir/test_vim9_cmd.vim +++ b/src/testdir/test_vim9_cmd.vim @@ -537,6 +537,22 @@ def Test_option_use_linebreak() CheckDefAndScriptSuccess(lines) enddef +def Test_register_use_linebreak() + var lines =<< trim END + new + @a = 'one' + @a->setline(1) + @b = 'two' + @b ->setline(2) + @c = 'three' + @c + ->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 --- 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 */ /**/ + 3367, +/**/ 3366, /**/ 3365,