Skip to content

Fix set_next_input with prompt_toolkit 1.0.10#10231

Merged
minrk merged 2 commits into
ipython:masterfrom
takluyver:set-next-in-ptk-fix
Feb 21, 2017
Merged

Fix set_next_input with prompt_toolkit 1.0.10#10231
minrk merged 2 commits into
ipython:masterfrom
takluyver:set-next-in-ptk-fix

Conversation

@takluyver
Copy link
Copy Markdown
Member

Closes gh-10229

Please don't merge this just yet.

@jonathanslenders I discovered after updating that we can no longer set text in the buffer with a pre_run function, because pre_run_callables reset the buffer immediately after that. I've worked around this by adding another callable to pre_run_callables which sets the text that I want, but I don't know if this is the right way to do it, or whether it works with previous releases of prompt_toolkit.

@Carreau Carreau changed the title Fix set_next_input with prompt_toolkit 1.0.10 [WIP] Fix set_next_input with prompt_toolkit 1.0.10 Feb 1, 2017
@jonathanslenders
Copy link
Copy Markdown
Contributor

Hi @takluyver,
I didn't realize you were relying on this.
This merge request is correct, but it will indeed not work for earlier versions of prompt_toolkit.
You may want to test for hasattr(self.pt_cli, 'pre_run_callables').
What is actually the use case for this? Why are you setting a text?

@takluyver
Copy link
Copy Markdown
Member Author

Thanks, I've pushed a fix that only uses pre_run_callables if the attribute is there, and otherwise just sets the document directly.

There are a few features in IPython that put some text at the next prompt; probably the most obvious is the %recall magic - %recall 1-3 will get inputs 1, 2 and 3 from your history, concatenate them and put them at the next prompt. They all go through a method shell.set_next_input().

@takluyver takluyver added this to the 5.3 milestone Feb 13, 2017
@takluyver takluyver changed the title [WIP] Fix set_next_input with prompt_toolkit 1.0.10 Fix set_next_input with prompt_toolkit 1.0.10 Feb 13, 2017
@takluyver
Copy link
Copy Markdown
Member Author

We're getting a number of bug reports that I believe this would fix, if someone would like to review it.

@minrk minrk merged commit 5f43012 into ipython:master Feb 21, 2017
@takluyver takluyver deleted the set-next-in-ptk-fix branch February 21, 2017 17:04
@takluyver
Copy link
Copy Markdown
Member Author

@meeseeksdev backport to 5.x

lumberbot-app Bot pushed a commit that referenced this pull request Feb 21, 2017
Closes gh-10229

Please don't merge this just yet.

 jonathanslenders I discovered after updating that we can no longer set text in the buffer with a `pre_run` function, because `pre_run_callables` reset the buffer immediately after that. I've worked around this by adding another callable to `pre_run_callables` which sets the text that I want, but I don't know if this is the right way to do it, or whether it works with previous releases of prompt_toolkit.
Carreau added a commit that referenced this pull request Feb 21, 2017
@Carreau Carreau added the backported PR that have been backported by MrMeeseeks label Feb 23, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backported PR that have been backported by MrMeeseeks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants