From 08114309a32d5afe3b60cbdc20ec569f6bf272c7 Mon Sep 17 00:00:00 2001 From: Kirottu Date: Fri, 14 Apr 2023 08:31:03 +0300 Subject: [PATCH] Switched to summing exec and name matches in the Applications plugin --- plugins/applications/src/lib.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/plugins/applications/src/lib.rs b/plugins/applications/src/lib.rs index fd2fffb..c263bb7 100644 --- a/plugins/applications/src/lib.rs +++ b/plugins/applications/src/lib.rs @@ -55,10 +55,14 @@ pub fn get_matches(input: RString, entries: &mut Vec<(DesktopEntry, u64)>) -> RV .clone() .into_iter() .filter_map(|(entry, id)| { - matcher - .fuzzy_match(&entry.name, &input) - .max(matcher.fuzzy_match(&entry.exec, &input)) - .map(|val| (entry, id, val)) + let score = matcher.fuzzy_match(&entry.name, &input).unwrap_or(0) + + matcher.fuzzy_match(&entry.exec, &input).unwrap_or(0); + + if score > 0 { + Some((entry, id, score)) + } else { + None + } }) .collect::>();