ipython: Multi line paste not working anymore in 5.0 beta

Copy the below text in the new ipython console:

x = 1
y = 2

and I only see the first line pasted.

I am using Windows 7, cmd command prompt, and using right clicking to paste. With previous versions of ipython this works (directly executing all but the last line, since there was no multi-line input).

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 23 (23 by maintainers)

Commits related to this issue

Most upvoted comments

New implementation: https://github.com/jonathanslenders/python-prompt-toolkit/pull/319

I’d appreciate if anyone with a Windows system can test this branch. It emulates bracketed paste on Windows. That means that if the input is detected as a paste, no indentation is added, nothing is automatically executed and all text is kept in one input field.

How do you feel if I can make pasting on Windows 99.9% accurate, but not 100%?

By this I mean, as far as I know, there is no way to detect when a user is pasting text, rather than typing fast. However, when pasting text, one ReadConsoleInputW will probably return multiple keys. (Up to 1024, according to the current setting.) This means, that if a user is pasting 1025 characters from which the last is a newline, then we will receive first one chunk of 1024 characters; process these; and later one single newline and process that separate. This means that in this particular case, it will be really hard to know whether this last newline was pasted or not. However, in the other cases, we can be rather confident, and emulate bracketed paste.