Mercurial > vim
diff src/register.c @ 22176:6941d3205be9 v8.2.1637
patch 8.2.1637: Vim9: :put ={expr} does not work inside :def function
Commit: https://github.com/vim/vim/commit/c3516f7e4507c77424b94cb89071f6d0841f4e6a
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Sep 8 22:45:35 2020 +0200
patch 8.2.1637: Vim9: :put ={expr} does not work inside :def function
Problem: Vim9: :put ={expr} does not work inside :def function.
Solution: Add ISN_PUT. (closes https://github.com/vim/vim/issues/6397)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 08 Sep 2020 23:00:04 +0200 |
parents | 2626306efe44 |
children | e82579016863 |
line wrap: on
line diff
--- a/src/register.c +++ b/src/register.c @@ -1487,6 +1487,7 @@ copy_yank_reg(yankreg_T *reg) void do_put( int regname, + char_u *expr_result, // result for regname "=" when compiled int dir, // BACKWARD for 'P', FORWARD for 'p' long count, int flags) @@ -1551,11 +1552,12 @@ do_put( // For special registers '%' (file name), '#' (alternate file name) and // ':' (last command line), etc. we have to create a fake yank register. - if (get_spec_reg(regname, &insert_string, &allocated, TRUE)) - { - if (insert_string == NULL) - return; - } + // For compiled code "expr_result" holds the expression result. + if (regname == '=' && expr_result != NULL) + insert_string = expr_result; + else if (get_spec_reg(regname, &insert_string, &allocated, TRUE) + && insert_string == NULL) + return; // Autocommands may be executed when saving lines for undo. This might // make "y_array" invalid, so we start undo now to avoid that.