diff --git a/CHANGELOG.md b/CHANGELOG.md index de8d4bc..9f14542 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +# [0.3.1] - 2023-12-22 + +## Bugfixes + +* fix Unicode substring matcher expecting an exact match (rejecting trailing characters) + # [0.3.0] - 2023-12-22 ## **Breaking Changes** diff --git a/matcher/src/exact.rs b/matcher/src/exact.rs index 9ebf31c..49388fd 100644 --- a/matcher/src/exact.rs +++ b/matcher/src/exact.rs @@ -245,7 +245,7 @@ impl Matcher { prev_class = char_class; let score = bonus * BONUS_FIRST_CHAR_MULTIPLIER + SCORE_MATCH; if score > max_score - && haystack[i + 1..] + && haystack[start + i + 1..start + i + needle.len()] .iter() .map(|c| c.normalize(&self.config)) .eq(needle[1..].iter().copied()) diff --git a/matcher/src/tests.rs b/matcher/src/tests.rs index f024023..abae3e6 100644 --- a/matcher/src/tests.rs +++ b/matcher/src/tests.rs @@ -470,26 +470,31 @@ fn test_normalize() { #[test] fn test_unicode() { + assert_matches( + &[FuzzyGreedy, FuzzyOptimal, Substring], + true, + false, + false, + false, + &[( + "你好世界", + "你好", + &[0, 1], + BONUS_BOUNDARY_WHITE * (BONUS_FIRST_CHAR_MULTIPLIER + 1), + )], + ); assert_matches( &[FuzzyGreedy, FuzzyOptimal], true, false, false, false, - &[ - ( - "你好世界", - "你好", - &[0, 1], - BONUS_BOUNDARY_WHITE * (BONUS_FIRST_CHAR_MULTIPLIER + 1), - ), - ( - "你好世界", - "你世", - &[0, 2], - BONUS_BOUNDARY_WHITE * BONUS_FIRST_CHAR_MULTIPLIER - PENALTY_GAP_START, - ), - ], + &[( + "你好世界", + "你世", + &[0, 2], + BONUS_BOUNDARY_WHITE * BONUS_FIRST_CHAR_MULTIPLIER - PENALTY_GAP_START, + )], ); assert_not_matches( false,