From b9ac6c9a20bf877bcfff77645473d39aa6cda5b7 Mon Sep 17 00:00:00 2001 From: Pascal Kuthe Date: Sun, 6 Aug 2023 20:01:02 +0200 Subject: [PATCH] correctly handle empty patterns in utility fuction --- src/lib.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index f1e9304..c98ae9b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -332,6 +332,9 @@ pub fn fuzzy_match>( case_matching: CaseMatching, ) -> Vec<(T, u32)> { 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); let mut buf = Vec::new(); let mut items: Vec<_> = items