Mercurial > vim
diff src/vim9execute.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 | a9e60176dcd3 |
children | efa1511a5bf3 |
line wrap: on
line diff
--- a/src/vim9execute.c +++ b/src/vim9execute.c @@ -2581,6 +2581,36 @@ call_def_function( } break; + case ISN_PUT: + { + int regname = iptr->isn_arg.put.put_regname; + linenr_T lnum = iptr->isn_arg.put.put_lnum; + char_u *expr = NULL; + int dir = FORWARD; + + if (regname == '=') + { + tv = STACK_TV_BOT(-1); + if (tv->v_type == VAR_STRING) + expr = tv->vval.v_string; + else + { + expr = typval_tostring(tv); // allocates value + clear_tv(tv); + } + --ectx.ec_stack.ga_len; + } + if (lnum == -2) + // :put! above cursor + dir = BACKWARD; + else if (lnum >= 0) + curwin->w_cursor.lnum = iptr->isn_arg.put.put_lnum; + check_cursor(); + do_put(regname, expr, dir, 1L, PUT_LINE|PUT_CURSLINE); + vim_free(expr); + } + break; + case ISN_SHUFFLE: { typval_T tmp_tv; @@ -3227,6 +3257,10 @@ ex_disassemble(exarg_T *eap) case ISN_2STRING_ANY: smsg("%4d 2STRING_ANY stack[%lld]", current, (long long)(iptr->isn_arg.number)); break; + case ISN_PUT: + smsg("%4d PUT %c %ld", current, iptr->isn_arg.put.put_regname, + (long)iptr->isn_arg.put.put_lnum); + break; case ISN_SHUFFLE: smsg("%4d SHUFFLE %d up %d", current, iptr->isn_arg.shuffle.shfl_item,