mirror of
https://github.com/solaeus/nucleo.git
synced 2024-12-21 09:37:48 +00:00
fix Unicode substring match requiring exact match
This commit is contained in:
parent
4a04baf6ba
commit
c7893db4b4
@ -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**
|
||||
|
@ -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())
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user