]> granicus.if.org Git - vim/commitdiff
patch 8.2.3475: expression register set by not executed put command v8.2.3475
authorkuuote <znmxodq1@gmail.com>
Mon, 4 Oct 2021 21:17:36 +0000 (22:17 +0100)
committerBram Moolenaar <Bram@vim.org>
Mon, 4 Oct 2021 21:17:36 +0000 (22:17 +0100)
Problem:    Expression register set by not executed put command.
Solution:   Do not set the register if the command is skipped. (closes #8909)

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

index 617de6f06d58a7b749b1e991b5b4f3ea18e5b076..2c55e67bc3701d80015a0c7a2a0ceac2053246dd 100644 (file)
@@ -2382,9 +2382,12 @@ do_one_cmd(
            // for '=' register: accept the rest of the line as an expression
            if (ea.arg[-1] == '=' && ea.arg[0] != NUL)
            {
-               set_expr_line(vim_strsave(ea.arg), &ea);
+               if (!ea.skip)
+               {
+                   set_expr_line(vim_strsave(ea.arg), &ea);
+                   did_set_expr_line = TRUE;
+               }
                ea.arg += STRLEN(ea.arg);
-               did_set_expr_line = TRUE;
            }
 #endif
            ea.arg = skipwhite(ea.arg);
index b080575e4026fe26065430c946ebbde270ceeddd..c3a911f6cb32868e8567f6a8b6bbe4e073de432b 100644 (file)
@@ -647,4 +647,12 @@ func Test_command_not_implemented_E319()
   endif
 endfunc
 
+func Test_not_break_expression_register()
+  call setreg('=', '1+1')
+  if 0
+    put =1
+  endif
+  call assert_equal('1+1', getreg('=', 1))
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab
index e92719172f7b86964da5a40176aab72352ef805f..e6a4b1ad5d8426a30315be1c798b0373b80843f1 100644 (file)
@@ -757,6 +757,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    3475,
 /**/
     3474,
 /**/