From b0111e469affbe23d4daac8f97c7049cad9244f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Nerma?= Date: Thu, 16 May 2024 10:20:09 +0200 Subject: [PATCH] Fix: handle queries with uppercase characters --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/index.rs | 8 +++++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e6b57f2..80b3803 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -161,7 +161,7 @@ checksum = "f8478577c03552c21db0e2724ffb8986a5ce7af88107e6be5d2ee6e158c12800" [[package]] name = "jumpy" -version = "0.4.2" +version = "0.4.3" dependencies = [ "clap", "dirs", diff --git a/Cargo.toml b/Cargo.toml index 8a79f08..1f9bd91 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "jumpy" -version = "0.4.2" +version = "0.4.3" edition = "2021" authors = ["Clément Nerma "] license = "Apache-2.0" diff --git a/src/index.rs b/src/index.rs index e545472..dc0be8d 100644 --- a/src/index.rs +++ b/src/index.rs @@ -72,14 +72,16 @@ impl Index { } pub fn query_all(&self, query: &str, after: Option<&str>) -> Vec { + let query = query.to_lowercase(); + let mut results = self .scored_entries .iter() - .filter(move |(path, _)| { + .filter(|(path, _)| { Path::new(path) .file_name() .and_then(|filename| filename.to_str()) - .filter(|filename| filename.to_lowercase().contains(query)) + .filter(|filename| filename.to_lowercase().contains(&query)) .is_some() }) .map(IndexEntry::from) @@ -118,7 +120,7 @@ impl Index { if let Component::Normal(component) = component && let Some(component) = component.to_str() { - component.to_lowercase().contains(query) + component.to_lowercase().contains(&query) } else { false }