Drop consecutive duplicates when refilling readline history #1003

Merged
merged 4 commits into from Nov 20, 2011

Projects

None yet

3 participants

@takluyver
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
Member

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
Member

Found the relevant bit for the Qt console too.

@minrk minrk and 1 other commented on an outdated diff Nov 15, 2011
IPython/core/interactiveshell.py
@@ -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()
@minrk
minrk Nov 15, 2011 IPython member

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

@takluyver
takluyver Nov 16, 2011 IPython member

Good point. Done.

@fperez
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 fperez merged commit 5e71407 into ipython:master Nov 20, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment