diff options
Diffstat (limited to 'crates/turtle/src/atuin_client/ordering.rs')
| -rw-r--r-- | crates/turtle/src/atuin_client/ordering.rs | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/crates/turtle/src/atuin_client/ordering.rs b/crates/turtle/src/atuin_client/ordering.rs index 446a5dac..84001f52 100644 --- a/crates/turtle/src/atuin_client/ordering.rs +++ b/crates/turtle/src/atuin_client/ordering.rs @@ -9,6 +9,7 @@ pub(crate) fn reorder_fuzzy(mode: SearchMode, query: &str, res: Vec<History>) -> } } +#[expect(clippy::needless_pass_by_value, reason = "makes things easier")] fn reorder<F, A>(query: &str, f: F, res: Vec<A>) -> Vec<A> where F: Fn(&A) -> &String, @@ -18,14 +19,12 @@ where let qvec = &query.chars().collect(); r.sort_by_cached_key(|h| { // TODO for fzf search we should sum up scores for each matched term - let (from, to) = match minspan::span(qvec, &(f(h).chars().collect())) { - Some(x) => x, - // this is a little unfortunate: when we are asked to match a query that is found nowhere, - // we don't want to return a None, as the comparison behaviour would put the worst matches - // at the front. therefore, we'll return a set of indices that are one larger than the longest - // possible legitimate match. This is meaningless except as a comparison. - None => (0, res.len()), - }; + // + // The fallback is a little unfortunate: when we are asked to match a query that is found nowhere, + // we don't want to return a None, as the comparison behaviour would put the worst matches + // at the front. Therefore, we'll return a set of indices that are one larger than the longest + // possible legitimate match. This is meaningless except as a comparison. + let (from, to) = minspan::span(qvec, &(f(h).chars().collect())).unwrap_or((0, res.len())); 1 + to - from }); r |
