Skip to content

Commit

Permalink
Fix: handle queries with uppercase characters
Browse files Browse the repository at this point in the history
  • Loading branch information
ClementNerma committed May 16, 2024
1 parent a0ad29b commit b0111e4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "jumpy"
version = "0.4.2"
version = "0.4.3"
edition = "2021"
authors = ["Clément Nerma <[email protected]>"]
license = "Apache-2.0"
Expand Down
8 changes: 5 additions & 3 deletions src/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,16 @@ impl Index {
}

pub fn query_all(&self, query: &str, after: Option<&str>) -> Vec<IndexEntry> {
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)
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit b0111e4

Please sign in to comment.