]> granicus.if.org Git - vim/commitdiff
patch 8.2.3367: Vim9: :@r executing a register is inconsistent v8.2.3367
authorBram Moolenaar <Bram@vim.org>
Sun, 22 Aug 2021 20:44:11 +0000 (22:44 +0200)
committerBram Moolenaar <Bram@vim.org>
Sun, 22 Aug 2021 20:44:11 +0000 (22:44 +0200)
Problem:    Vim9: :@r executing a register is inconsistent.
Solution:   Use "@r" as the start of an expression. (issue #8779)

src/ex_docmd.c
src/testdir/test_vim9_cmd.vim
src/version.c

index 4eee8fe9cecb00f1e4b7f1a549525272c4abd3a5..85df6cdc2784d2214106125da571b3e814c1576f 100644 (file)
@@ -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 <NL>" is the start of an expression.
+                   // "&option <NL>" and "@r <NL>" 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)
            {
index 4b3cbc6787f03fed2e54ef746b27404f0d0de6e9..ec845ea40bd92ac6104aaf5c45edb94b388fdd26 100644 (file)
@@ -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 = []
index ca5402fdad8a426bae8c2d84f7b25a1dec812c6a..619c840f9a123e8383c4be0cc15176ff87280a8f 100644 (file)
@@ -755,6 +755,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    3367,
 /**/
     3366,
 /**/