To: vim_dev@googlegroups.com Subject: Patch 8.2.3307 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.3307 Problem: Vim9: :echoconsole cannot access local variables. Solution: Handle like other :echo commands. (closes #8708) Files: src/vim9compile.c, src/vim9.h, src/vim9execute.c, src/testdir/test_vim9_script.vim, src/testdir/test_vim9_disassemble.vim *** ../vim-8.2.3306/src/vim9compile.c 2021-08-07 13:26:47.851191736 +0200 --- src/vim9compile.c 2021-08-07 14:59:13.664332425 +0200 *************** *** 8754,8759 **** --- 8754,8760 ---- * compile "echo expr" * compile "echomsg expr" * compile "echoerr expr" + * compile "echoconsole expr" * compile "execute expr" */ static char_u * *************** *** 8804,8809 **** --- 8805,8812 ---- generate_MULT_EXPR(cctx, ISN_EXECUTE, count); else if (cmdidx == CMD_echomsg) generate_MULT_EXPR(cctx, ISN_ECHOMSG, count); + else if (cmdidx == CMD_echoconsole) + generate_MULT_EXPR(cctx, ISN_ECHOCONSOLE, count); else generate_MULT_EXPR(cctx, ISN_ECHOERR, count); *************** *** 9861,9867 **** case CMD_execute: case CMD_echomsg: case CMD_echoerr: ! // TODO: "echoconsole" line = compile_mult_expr(p, ea.cmdidx, &cctx); break; --- 9864,9870 ---- case CMD_execute: case CMD_echomsg: case CMD_echoerr: ! case CMD_echoconsole: line = compile_mult_expr(p, ea.cmdidx, &cctx); break; *************** *** 10307,10312 **** --- 10310,10316 ---- case ISN_DEBUG: case ISN_DROP: case ISN_ECHO: + case ISN_ECHOCONSOLE: case ISN_ECHOERR: case ISN_ECHOMSG: case ISN_ENDTRY: *** ../vim-8.2.3306/src/vim9.h 2021-08-07 12:44:37.836256707 +0200 --- src/vim9.h 2021-08-07 14:57:04.940758358 +0200 *************** *** 16,25 **** ISN_EXECCONCAT, // execute Ex command from isn_arg.number items on stack ISN_EXEC_SPLIT, // execute Ex command from isn_arg.string split at NL ISN_LEGACY_EVAL, // evaluate expression isn_arg.string with legacy syntax. ! ISN_ECHO, // echo isn_arg.echo.echo_count items on top of stack ! ISN_EXECUTE, // execute Ex commands isn_arg.number items on top of stack ! ISN_ECHOMSG, // echo Ex commands isn_arg.number items on top of stack ! ISN_ECHOERR, // echo Ex commands isn_arg.number items on top of stack ISN_RANGE, // compute range from isn_arg.string, push to stack ISN_SUBSTITUTE, // :s command with expression ISN_INSTR, // instructions compiled from expression --- 16,26 ---- ISN_EXECCONCAT, // execute Ex command from isn_arg.number items on stack ISN_EXEC_SPLIT, // execute Ex command from isn_arg.string split at NL ISN_LEGACY_EVAL, // evaluate expression isn_arg.string with legacy syntax. ! ISN_ECHO, // :echo with isn_arg.echo.echo_count items on top of stack ! ISN_EXECUTE, // :execute with isn_arg.number items on top of stack ! ISN_ECHOMSG, // :echomsg with isn_arg.number items on top of stack ! ISN_ECHOCONSOLE, // :echoconsole with isn_arg.number items on top of stack ! ISN_ECHOERR, // :echoerr with isn_arg.number items on top of stack ISN_RANGE, // compute range from isn_arg.string, push to stack ISN_SUBSTITUTE, // :s command with expression ISN_INSTR, // instructions compiled from expression *** ../vim-8.2.3306/src/vim9execute.c 2021-08-07 12:44:37.836256707 +0200 --- src/vim9execute.c 2021-08-07 14:59:55.768196046 +0200 *************** *** 1869,1877 **** --- 1869,1879 ---- // :execute {string} ... // :echomsg {string} ... + // :echoconsole {string} ... // :echoerr {string} ... case ISN_EXECUTE: case ISN_ECHOMSG: + case ISN_ECHOCONSOLE: case ISN_ECHOERR: { int count = iptr->isn_arg.number; *************** *** 1941,1946 **** --- 1943,1954 ---- msg_attr(ga.ga_data, echo_attr); out_flush(); } + else if (iptr->isn_type == ISN_ECHOCONSOLE) + { + ui_write(ga.ga_data, (int)STRLEN(ga.ga_data), + TRUE); + ui_write((char_u *)"\r\n", 2, TRUE); + } else { SOURCING_LNUM = iptr->isn_lnum; *************** *** 4900,4914 **** break; case ISN_EXECUTE: smsg("%s%4d EXECUTE %lld", pfx, current, ! (varnumber_T)(iptr->isn_arg.number)); break; case ISN_ECHOMSG: smsg("%s%4d ECHOMSG %lld", pfx, current, ! (varnumber_T)(iptr->isn_arg.number)); break; case ISN_ECHOERR: smsg("%s%4d ECHOERR %lld", pfx, current, ! (varnumber_T)(iptr->isn_arg.number)); break; case ISN_LOAD: { --- 4908,4926 ---- break; case ISN_EXECUTE: smsg("%s%4d EXECUTE %lld", pfx, current, ! (varnumber_T)(iptr->isn_arg.number)); break; case ISN_ECHOMSG: smsg("%s%4d ECHOMSG %lld", pfx, current, ! (varnumber_T)(iptr->isn_arg.number)); ! break; ! case ISN_ECHOCONSOLE: ! smsg("%s%4d ECHOCONSOLE %lld", pfx, current, ! (varnumber_T)(iptr->isn_arg.number)); break; case ISN_ECHOERR: smsg("%s%4d ECHOERR %lld", pfx, current, ! (varnumber_T)(iptr->isn_arg.number)); break; case ISN_LOAD: { *** ../vim-8.2.3306/src/testdir/test_vim9_script.vim 2021-08-07 13:26:47.851191736 +0200 --- src/testdir/test_vim9_script.vim 2021-08-07 14:53:41.897465265 +0200 *************** *** 2493,2502 **** enddef def Test_echoerr_cmd() try ! echoerr 'something' 'wrong' # comment catch ! assert_match('something wrong', v:exception) endtry enddef --- 2493,2503 ---- enddef def Test_echoerr_cmd() + var local = 'local' try ! echoerr 'something' local 'wrong' # comment catch ! assert_match('something local wrong', v:exception) endtry enddef *************** *** 2515,2520 **** --- 2516,2527 ---- CheckScriptSuccess(lines) enddef + def Test_echoconsole_cmd() + var local = 'local' + echoconsole 'something' local # comment + # output goes anywhere + enddef + def Test_for_outside_of_function() var lines =<< trim END vim9script *** ../vim-8.2.3306/src/testdir/test_vim9_disassemble.vim 2021-08-01 14:08:50.780946552 +0200 --- src/testdir/test_vim9_disassemble.vim 2021-08-07 15:04:24.103352455 +0200 *************** *** 1938,1943 **** --- 1938,1944 ---- def s:Echomsg() echomsg 'some' 'message' + echoconsole 'nothing' echoerr 'went' .. 'wrong' enddef *************** *** 1948,1953 **** --- 1949,1957 ---- '\d PUSHS "some"\_s*' .. '\d PUSHS "message"\_s*' .. '\d ECHOMSG 2\_s*' .. + "echoconsole 'nothing'\\_s*" .. + '\d PUSHS "nothing"\_s*' .. + '\d ECHOCONSOLE 1\_s*' .. "echoerr 'went' .. 'wrong'\\_s*" .. '\d PUSHS "wentwrong"\_s*' .. '\d ECHOERR 1\_s*' .. *** ../vim-8.2.3306/src/version.c 2021-08-07 13:59:38.298919436 +0200 --- src/version.c 2021-08-07 15:04:46.475283713 +0200 *************** *** 757,758 **** --- 757,760 ---- { /* Add new patch number below this line */ + /**/ + 3307, /**/ -- WOMAN: I didn't know we had a king. I thought we were an autonomous collective. DENNIS: You're fooling yourself. We're living in a dictatorship. A self-perpetuating autocracy in which the working classes-- WOMAN: Oh there you go, bringing class into it again. DENNIS: That's what it's all about if only people would-- The Quest for the Holy Grail (Monty Python) /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///