# HG changeset patch # User Bram Moolenaar # Date 1633383003 -7200 # Node ID 826c36b4640b9fb303c04c4ce24c5068a431b509 # Parent c7830dd110a789dfc910b9c056bb8735538dcb11 patch 8.2.3475: expression register set by not executed put command Commit: https://github.com/vim/vim/commit/08d7b1c82866a61b61a55e55b6c190dba04e54ea Author: kuuote Date: Mon Oct 4 22:17:36 2021 +0100 patch 8.2.3475: expression register set by not executed put command Problem: Expression register set by not executed put command. Solution: Do not set the register if the command is skipped. (closes https://github.com/vim/vim/issues/8909) diff --git a/src/ex_docmd.c b/src/ex_docmd.c --- a/src/ex_docmd.c +++ b/src/ex_docmd.c @@ -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); diff --git a/src/testdir/test_excmd.vim b/src/testdir/test_excmd.vim --- a/src/testdir/test_excmd.vim +++ b/src/testdir/test_excmd.vim @@ -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 diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -758,6 +758,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 3475, +/**/ 3474, /**/ 3473,