-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
only show unique entries in history search when filtering #60066
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
Conversation
|
How do the up and down arrow keys work with this. I sometimes deliberately choose a different identical copy not for the contents, but for the place in history (no pun intended). |
|
So, I've already got something like this in #59953 (now that I look, it may not be pushed though: I brought in some commits from another PR to try building on, so I'll need to do some cherry-picking). There's a key difference in the approaches we've taken though, and I wonder which behaviour we actually want: here we use an allocated By contrast, I use the history content + mode + status to deduplicate consecutive entries. At the moment, I feel like this is probably the preferable behaviour, since I also like the history as a log of what I've done that I can look at, and this preserves that aspect better while getting rid of consecutive duplicates. I also like that the implementation is |
|
@tecosaur If you have an alternative implementation that you say perform better please put it up so it can actually be benchmarked against. And please make it a separate change instead of in the amalgamation PR.
Can you elaborate on this. You write |
Yea, I'll pick the bugfixes and tweaks off that so we can discuss/merge them separately to the expanded history format. Let's me know if you have a preference between a "minor changes" PR vs. individual fix/tweak PRs. |
Usually not the sixth, but the second from the bottom because I messed up whatever sequence I was testing in the latest iteration and want to start over with the previous one (by hitting down arrow after running the line) |
I'm not sure that feature exists any more with the new history search. But note that you can select multiple entries (with tab) so if you want a set of changes you can just bring all of those in in one go. |
|
Filtering out repeats seems to at least be done for whatever default behavior I have with zsh + fzf. |
…e duplicates when not filtering
|
I changed this to not remove duplicates when you are not filtering in case you want to go and tab-collect a collection of consecutive ones them earlier use. Also fixed not creating a Set inside the function that is called repeatedly when collecting entries to show. |
|
Three things:
|
e87a137 to
9a89549
Compare
- use a consistent type for `seen` and pass in if we should deduplicate - reuse a set accross searches
9a89549 to
0d6e7eb
Compare
|
updated based on that |
|
One further comment: When |
I did do that change already (but not in the way you described). |
|
I have a feeling my comments came (i.e. were written) mid force-pushed changes, I'll have a look at the latest. |
|
Hmm, I know To this end, I'd advocate for a signature dropping filterchunkrev!(state::SelectorState, candidates::DenseVector{HistEntry}, seen::Set{Tuple{Symbol, String}}, idx::Int = length(candidates);
maxtime::Float64 = Inf, maxresults::Int = length(candidates))and skipping It would also allow us to drop the Unless there's something I've missed? Edit: I'm thinking something like this: cands_current = hist
if isempty(filter_spec.exacts) && isempty(filter_spec.negatives) &&
isempty(filter_spec.regexps) && isempty(filter_spec.modes)
# No filtering needed, show all history
filter_idx = 0
append!(state.candidates, cands_current)
else
# Find the most strict candidate list available
for (cond, cands) in Iterators.reverse(cands_cache)
if ismorestrict(cands_cond, cond)
cands_current = cands
break
end
end
# Start filtering candidates
empty!(filter_seen)
filter_idx = filterchunkrev!(
state, cands_current, seen;
maxtime = time() + 0.01,
maxresults = outsize[1])
end |
17f256c to
aff738e
Compare
|
👍 |
tecosaur
left a comment
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.
I'm pretty happy with how this all looks now, thanks for putting up with my nitpicks!
|
Thanks for review! |
|
Cross posting from Zulip: Basically Run length encoding the (currently shown, filtered or not) history. Independent in behavior if I am filtering or not. Same behavior, but auto off normally and auto on when filtering (which can then be toggled and configured (how many entries to show before collapsing)). It would only need a I know it would be a rather big change and Maybe It's too late and this train is gone, but in any case thanks for this work on the REPL 😊 |
|
I will merge this because I think it is an improvement over status quo but it could be modified in the future. Regarding what you wrote, Think about the following history (each line is an entry): and Now you filter on |
Co-authored-by: KristofferC <[email protected]> (cherry picked from commit 6058082)
Co-authored-by: KristofferC <[email protected]> (cherry picked from commit 6058082)
I quite often get the whole history search filled with duplicates which feels like low signal ratio. This only keep uniques:
Before vs after
cc @tecosaur @topolarity
Tests written by Claude Code 🤖