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
Conversation
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. |
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() |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. Done.
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. |
Drop consecutive duplicates when refilling history, both in the terminal (via readline) and in the qt console.
Drop consecutive duplicates when refilling history, both in the terminal (via readline) and in the qt console.
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.