You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Multi-line input only processes the first line #9948
With ipython 5.0 and 5.1 (from anaconda) I have the issue that multiple lines of input in one batch via the tty are not processed correctly. Only the first line is evaluated. This can be verified via tmux and the send-keys feature:
Start ipython in a tmux session:
tmux new -s test ipython
And send two lines of code in one batch from another terminal:
tmux send-keys -t 'test' 'print 42' Enter 'print 44' Enter
Hum, that's probably because the event arrive to fast for processing.
You are basically typing print 44 while IPython in in between two prompt, as "enter" is both new line and execute (depending if the input is "complete" or not).
if you try tmux send-keys -t 'test' 'for i in range(10):' Enter 'print 44' Enter if should work.
We need to bind a shortcut that adds a new line without executing, if you are scripting you can use C-o Down to force a newline and Escape Enter to force execution.
My expectation would be that the unprocessed characters after the first enter are just queued up and processed once the first execution returns. This is the behavior that existed in previous versions and which I am used to from basically any other command-line based tool. Simply swallowing key presses doesn't sound nice to me.
My expectation would be that the unprocessed characters after the first
enter are just queued up and processed once the first execution returns.
This is the behavior that existed in previous versions and which I am used
to from basically any other command-line based tool. Simply swallowing key
presses doesn't sound nice to me.
I guess the problem here is the send-keys command of tmux doesn't send keystrokes using bracketed paste. If you wrap everything in bracketed paste characters, then I think it should work.
I think paste is just one way of demonstrating the problem.
Using ipython -im MODULE (or ipython -i SCRIPT) the repl can be delayed while the module or script is loaded, making it easy to type in multiple lines without using paste at all.
I hit this all the time just because of ipython's slow startup. I often find myself writing a couple of lines of code in the time it takes to load, and only the first of them is executed. --simple-prompt and rlwrap makes it usable again, but disables all the useful tab completion.
Activity
Carreau commentedon Sep 17, 2016
Hum, that's probably because the event arrive to fast for processing.
You are basically typing
print 44while IPython in in between two prompt, as "enter" is both new line and execute (depending if the input is "complete" or not).if you try
tmux send-keys -t 'test' 'for i in range(10):' Enter 'print 44' Enterif should work.We need to bind a shortcut that adds a new line without executing, if you are scripting you can use
C-o Downto force a newline andEscape Enterto force execution.languitar commentedon Sep 17, 2016
My expectation would be that the unprocessed characters after the first enter are just queued up and processed once the first execution returns. This is the behavior that existed in previous versions and which I am used to from basically any other command-line based tool. Simply swallowing key presses doesn't sound nice to me.
Carreau commentedon Sep 17, 2016
I agree, I was just offering a work around. Though because of IPython
architecture it might not be that easy to fix.
The --simple-prompt option might fix that as well, but then you will lose
most of the bells and whistles, syntactic coloration and multiline edit.
Unfortunately there is a trade-off
On Sep 17, 2016 05:05, "Johannes Wienke" [email protected] wrote:
ivanov commentedon Mar 2, 2017
This issue may be the same as the one described in #9948. I want to address this by tackling #10364.
jonathanslenders commentedon Mar 4, 2017
I guess the problem here is the
send-keyscommand of tmux doesn't send keystrokes using bracketed paste. If you wrap everything in bracketed paste characters, then I think it should work.See: https://cirw.in/blog/bracketed-paste
groner commentedon Feb 20, 2018
I think paste is just one way of demonstrating the problem.
Using
ipython -im MODULE(oripython -i SCRIPT) the repl can be delayed while the module or script is loaded, making it easy to type in multiple lines without using paste at all.marksteward commentedon Sep 9, 2018
I hit this all the time just because of ipython's slow startup. I often find myself writing a couple of lines of code in the time it takes to load, and only the first of them is executed.
--simple-promptandrlwrapmakes it usable again, but disables all the useful tab completion.