Merge 14bba8f264 into c8a47a068b
This commit is contained in:
commit
41ae471f68
|
|
@ -83,7 +83,10 @@ impl<'a> Stream<'a> {
|
||||||
None => return true,
|
None => return true,
|
||||||
};
|
};
|
||||||
|
|
||||||
let path = util::to_lowercase(path);
|
let mut path = util::to_lowercase(path);
|
||||||
|
if cfg!(windows) {
|
||||||
|
path = path.replace('\\', "/");
|
||||||
|
}
|
||||||
let mut path = path.as_str();
|
let mut path = path.as_str();
|
||||||
match path.rfind(keywords_last) {
|
match path.rfind(keywords_last) {
|
||||||
Some(idx) => {
|
Some(idx) => {
|
||||||
|
|
@ -208,4 +211,16 @@ mod tests {
|
||||||
let stream = Stream::new(db, options);
|
let stream = Stream::new(db, options);
|
||||||
assert_eq!(is_match, stream.filter_by_keywords(path));
|
assert_eq!(is_match, stream.filter_by_keywords(path));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Forward slash matching on Windows-style paths
|
||||||
|
#[cfg(windows)]
|
||||||
|
#[rstest]
|
||||||
|
#[case(&["bar/meow"], r"~\foo\bar\meow", true)]
|
||||||
|
#[case(&["bar", "meow"], r"~\foo\bar\meow", true)]
|
||||||
|
fn query_windows(#[case] keywords: &[&str], #[case] path: &str, #[case] is_match: bool) {
|
||||||
|
let db = &mut Database::new(PathBuf::new(), Vec::new(), |_| Vec::new(), false);
|
||||||
|
let options = StreamOptions::new(0).with_keywords(keywords.iter());
|
||||||
|
let stream = Stream::new(db, options);
|
||||||
|
assert_eq!(is_match, stream.filter_by_keywords(path));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue