Syntax errors in console.html are not printed immediately, only after the next command is submitted. E.g., type 1+<ENTER> into console.html.
1+<ENTER>
I think this was introduced in #1125. I investigated but I can’t figure out why it’s happening. Any ideas @casatir?
The why it happens only for syntax errors (and not runtime errors) can be understood with this three lines:
const prompt = pyconsole.push(c) ? ps2 : ps1; term.set_prompt(prompt); await pyconsole.run_complete;
Execution steps for runtime errors (or even code exec without any error) are:
pyconsole.push(c)
false
>>>
run_complete
stderr
While for syntax error, we have:
set_prompt
await
I opened a PR: https://github.com/jcubic/jquery.terminal/pull/652
I think I got it. In console.html, we continuously set the prompt:
console.html
async function interpreter(command) { // multiline should be splitted (usefull when pasting) term.pause(); for( const c of command.split('\n') ) { const prompt = pyconsole.push(c) ? ps2 : ps1; term.set_prompt(prompt); await pyconsole.run_complete; } term.resume(); }
which disturb echo_newline.js since it also set the prompt…
echo_newline.js
The why it happens only for syntax errors (and not runtime errors) can be understood with this three lines:
Execution steps for runtime errors (or even code exec without any error) are:
pyconsole.push(c)returnsfalse(code is not yet executed)>>>run_completepromise), error is printed tostderrWhile for syntax error, we have:
pyconsole.push(c)prints syntax error tostderr(and returnfalse)set_promptrun_completeis a dummy promise so theawaithas no effect.I opened a PR: https://github.com/jcubic/jquery.terminal/pull/652
I think I got it. In
console.html, we continuously set the prompt:which disturb
echo_newline.jssince it also set the prompt…