correctly handle empty patterns in utility fuction

This commit is contained in:
Pascal Kuthe 2023-08-06 20:01:02 +02:00
parent 4fc0281dd7
commit b9ac6c9a20
No known key found for this signature in database
GPG Key ID: D715E8655AE166A6

View File

@ -332,6 +332,9 @@ pub fn fuzzy_match<T: AsRef<str>>(
case_matching: CaseMatching, case_matching: CaseMatching,
) -> Vec<(T, u32)> { ) -> Vec<(T, u32)> {
let mut pattern_ = Pattern::new(&matcher.config, case_matching); let mut pattern_ = Pattern::new(&matcher.config, case_matching);
if pattern_.is_empty() {
return items.into_iter().map(|item| (item, 0)).collect();
}
pattern_.set_literal(pattern, PatternKind::Fuzzy, false); pattern_.set_literal(pattern, PatternKind::Fuzzy, false);
let mut buf = Vec::new(); let mut buf = Vec::new();
let mut items: Vec<_> = items let mut items: Vec<_> = items