Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop consecutive duplicates when refilling readline history #1003

Merged
merged 4 commits into from Nov 20, 2011

Conversation

takluyver
Copy link
Member

I'd better fix that bug if I'm getting a tshirt for it.

This operates at the cell level, even if the user disables multiline_history in the terminal, so you can define a multiline function twice, and only have to flip through it once after you start a new session.

There's an added bonus fix for setting the next input at the terminal on Python 3.

@takluyver
Copy link
Member Author

Aside: the equivalent thing also needs fixing in the Qt console. I'll see if I can track down the relevant code and add it to this PR.

@takluyver
Copy link
Member Author

Found the relevant bit for the Qt console too.

@@ -1804,6 +1806,7 @@ class InteractiveShell(SingletonConfigurable, Magic):
for line in cell.splitlines():
self.readline.add_history(py3compat.unicode_to_str(line,
stdin_encoding))
last_cell = cell.rstrip()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can eliminate these three strip()/rstrip() calls by using a single stripped = cell.rstrip(), and if stripped and stripped != last_cell:, yes?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Done.

@fperez
Copy link
Member

fperez commented Nov 20, 2011

Looks great, works great, and fixes a really annoying little regression.

Great job, as always. Totally deserving of the issue #1000 award!! :) Will merge now, thanks a lot.

fperez added a commit that referenced this pull request Nov 20, 2011
Drop consecutive duplicates when refilling history, both in the terminal (via readline) and in the qt console.
@fperez fperez merged commit 5e71407 into ipython:master Nov 20, 2011
mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this pull request Nov 3, 2014
Drop consecutive duplicates when refilling history, both in the terminal (via readline) and in the qt console.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants