forked from aniani/vim
patch 8.2.3307: Vim9: :echoconsole cannot access local variables
Problem: Vim9: :echoconsole cannot access local variables. Solution: Handle like other :echo commands. (closes #8708)
This commit is contained in:
parent
1b154ea121
commit
7de6262373
@ -1938,6 +1938,7 @@ enddef
|
||||
|
||||
def s:Echomsg()
|
||||
echomsg 'some' 'message'
|
||||
echoconsole 'nothing'
|
||||
echoerr 'went' .. 'wrong'
|
||||
enddef
|
||||
|
||||
@ -1948,6 +1949,9 @@ def Test_disassemble_echomsg()
|
||||
'\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*' ..
|
||||
|
@ -2493,10 +2493,11 @@ def Test_echomsg_cmd_vimscript()
|
||||
enddef
|
||||
|
||||
def Test_echoerr_cmd()
|
||||
var local = 'local'
|
||||
try
|
||||
echoerr 'something' 'wrong' # comment
|
||||
echoerr 'something' local 'wrong' # comment
|
||||
catch
|
||||
assert_match('something wrong', v:exception)
|
||||
assert_match('something local wrong', v:exception)
|
||||
endtry
|
||||
enddef
|
||||
|
||||
@ -2515,6 +2516,12 @@ def Test_echoerr_cmd_vimscript()
|
||||
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
|
||||
|
@ -755,6 +755,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
3307,
|
||||
/**/
|
||||
3306,
|
||||
/**/
|
||||
|
@ -16,10 +16,11 @@ typedef enum {
|
||||
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_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
|
||||
|
@ -8754,6 +8754,7 @@ compile_eval(char_u *arg, cctx_T *cctx)
|
||||
* compile "echo expr"
|
||||
* compile "echomsg expr"
|
||||
* compile "echoerr expr"
|
||||
* compile "echoconsole expr"
|
||||
* compile "execute expr"
|
||||
*/
|
||||
static char_u *
|
||||
@ -8804,6 +8805,8 @@ compile_mult_expr(char_u *arg, int cmdidx, cctx_T *cctx)
|
||||
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,7 +9864,7 @@ compile_def_function(
|
||||
case CMD_execute:
|
||||
case CMD_echomsg:
|
||||
case CMD_echoerr:
|
||||
// TODO: "echoconsole"
|
||||
case CMD_echoconsole:
|
||||
line = compile_mult_expr(p, ea.cmdidx, &cctx);
|
||||
break;
|
||||
|
||||
@ -10307,6 +10310,7 @@ delete_instr(isn_T *isn)
|
||||
case ISN_DEBUG:
|
||||
case ISN_DROP:
|
||||
case ISN_ECHO:
|
||||
case ISN_ECHOCONSOLE:
|
||||
case ISN_ECHOERR:
|
||||
case ISN_ECHOMSG:
|
||||
case ISN_ENDTRY:
|
||||
|
@ -1869,9 +1869,11 @@ exec_instructions(ectx_T *ectx)
|
||||
|
||||
// :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,6 +1943,12 @@ exec_instructions(ectx_T *ectx)
|
||||
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,15 +4908,19 @@ list_instructions(char *pfx, isn_T *instr, int instr_count, ufunc_T *ufunc)
|
||||
break;
|
||||
case ISN_EXECUTE:
|
||||
smsg("%s%4d EXECUTE %lld", pfx, current,
|
||||
(varnumber_T)(iptr->isn_arg.number));
|
||||
(varnumber_T)(iptr->isn_arg.number));
|
||||
break;
|
||||
case ISN_ECHOMSG:
|
||||
smsg("%s%4d ECHOMSG %lld", pfx, current,
|
||||
(varnumber_T)(iptr->isn_arg.number));
|
||||
(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));
|
||||
(varnumber_T)(iptr->isn_arg.number));
|
||||
break;
|
||||
case ISN_LOAD:
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user