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

Only append entry to REPL history if it is not the same as last entry #252

Merged
merged 2 commits into from
Oct 20, 2021

Conversation

Alexander-Block
Copy link
Collaborator

Closes #75.
A REPL entry is only appended to the REPL history if it is not a duplicate of the last entry.

@byorgey
Copy link
Member

byorgey commented Oct 20, 2021

Thanks! This all looks good, however it looks a bit strange because we also use the REPL history for deciding what to display in the REPL. So if you enter the same as the previous entry, the output shows up again but your input is not shown:

REPL-repeat

Ideally the input should still be shown a second time in the REPL window, but when you use the up/down arrow keys it will only show up once.

I guess one way to solve this would be to add another Boolean field to a REPLEntry saying whether it is a duplicate, and then to ignore such entries when scrolling through the history with up/down.

@Alexander-Block
Copy link
Collaborator Author

Thank you for pointing out this strange behaviour; somehow I overlooked this.
I agree that it is necessary then not to completely discard duplicate REPL entries. I have implemented your proposal to mark duplicate entries using a second Boolean field in a REPLEntry and filter duplicates out only when scrolling through the history with up/down.

Copy link
Member

@byorgey byorgey left a comment

Choose a reason for hiding this comment

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

Works great, thanks!

@byorgey byorgey added the merge me Trigger the merge process of the Pull request. label Oct 20, 2021
@mergify mergify bot merged commit 969b0d1 into main Oct 20, 2021
@mergify mergify bot deleted the remove-consecutive-duplicates-in-repl-history branch October 20, 2021 21:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge me Trigger the merge process of the Pull request.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove duplicate entries in the REPL history
2 participants