From 73be69cd99f5a4784fe69f5d78f423c72e837284 Mon Sep 17 00:00:00 2001 From: Benedikt Peetz Date: Mon, 20 Jul 2026 12:57:36 +0200 Subject: chore: Commit --- crates/client/src/atuin_client/ordering.rs | 31 ------------------------------ 1 file changed, 31 deletions(-) delete mode 100644 crates/client/src/atuin_client/ordering.rs (limited to 'crates/client/src/atuin_client/ordering.rs') diff --git a/crates/client/src/atuin_client/ordering.rs b/crates/client/src/atuin_client/ordering.rs deleted file mode 100644 index 84001f52..00000000 --- a/crates/client/src/atuin_client/ordering.rs +++ /dev/null @@ -1,31 +0,0 @@ -use minspan::minspan; - -use super::{history::History, settings::SearchMode}; - -pub(crate) fn reorder_fuzzy(mode: SearchMode, query: &str, res: Vec) -> Vec { - match mode { - SearchMode::Fuzzy => reorder(query, |x| &x.command, res), - _ => res, - } -} - -#[expect(clippy::needless_pass_by_value, reason = "makes things easier")] -fn reorder(query: &str, f: F, res: Vec) -> Vec -where - F: Fn(&A) -> &String, - A: Clone, -{ - let mut r = res.clone(); - let qvec = &query.chars().collect(); - r.sort_by_cached_key(|h| { - // TODO for fzf search we should sum up scores for each matched term - // - // 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 -} -- cgit v1.3.1