Fix set_next_input with prompt_toolkit 1.0.10 #10231

Merged
merged 2 commits into from Feb 21, 2017

Conversation

Projects
None yet
4 participants
@takluyver
Member

takluyver commented Feb 1, 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 Carreau changed the title from Fix set_next_input with prompt_toolkit 1.0.10 to [WIP] Fix set_next_input with prompt_toolkit 1.0.10 Feb 1, 2017

@jonathanslenders

This comment has been minimized.

Show comment
Hide comment
@jonathanslenders

jonathanslenders Feb 1, 2017

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?

Contributor

jonathanslenders commented Feb 1, 2017

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

This comment has been minimized.

Show comment
Hide comment
@takluyver

takluyver Feb 1, 2017

Member

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().

Member

takluyver commented Feb 1, 2017

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 from [WIP] Fix set_next_input with prompt_toolkit 1.0.10 to Fix set_next_input with prompt_toolkit 1.0.10 Feb 13, 2017

@takluyver

This comment has been minimized.

Show comment
Hide comment
@takluyver

takluyver Feb 16, 2017

Member

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

Member

takluyver commented Feb 16, 2017

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

2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@takluyver takluyver deleted the takluyver:set-next-in-ptk-fix branch Feb 21, 2017

@takluyver

This comment has been minimized.

Show comment
Hide comment
@takluyver

takluyver Feb 21, 2017

Member

@meeseeksdev backport to 5.x

Member

takluyver commented Feb 21, 2017

@meeseeksdev backport to 5.x

meeseeksdev bot pushed a commit that referenced this pull request Feb 21, 2017

Backport PR #10231: Fix set_next_input with prompt_toolkit 1.0.10
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 label Feb 23, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment