mirror of
https://github.com/solaeus/nucleo.git
synced 2024-12-22 01:47:49 +00:00
fix Unicode substring match requiring exact match
This commit is contained in:
parent
4a04baf6ba
commit
c7893db4b4
@ -1,5 +1,11 @@
|
|||||||
# Changelog
|
# 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
|
# [0.3.0] - 2023-12-22
|
||||||
|
|
||||||
## **Breaking Changes**
|
## **Breaking Changes**
|
||||||
|
@ -245,7 +245,7 @@ impl Matcher {
|
|||||||
prev_class = char_class;
|
prev_class = char_class;
|
||||||
let score = bonus * BONUS_FIRST_CHAR_MULTIPLIER + SCORE_MATCH;
|
let score = bonus * BONUS_FIRST_CHAR_MULTIPLIER + SCORE_MATCH;
|
||||||
if score > max_score
|
if score > max_score
|
||||||
&& haystack[i + 1..]
|
&& haystack[start + i + 1..start + i + needle.len()]
|
||||||
.iter()
|
.iter()
|
||||||
.map(|c| c.normalize(&self.config))
|
.map(|c| c.normalize(&self.config))
|
||||||
.eq(needle[1..].iter().copied())
|
.eq(needle[1..].iter().copied())
|
||||||
|
@ -470,26 +470,31 @@ fn test_normalize() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_unicode() {
|
fn test_unicode() {
|
||||||
|
assert_matches(
|
||||||
|
&[FuzzyGreedy, FuzzyOptimal, Substring],
|
||||||
|
true,
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
&[(
|
||||||
|
"你好世界",
|
||||||
|
"你好",
|
||||||
|
&[0, 1],
|
||||||
|
BONUS_BOUNDARY_WHITE * (BONUS_FIRST_CHAR_MULTIPLIER + 1),
|
||||||
|
)],
|
||||||
|
);
|
||||||
assert_matches(
|
assert_matches(
|
||||||
&[FuzzyGreedy, FuzzyOptimal],
|
&[FuzzyGreedy, FuzzyOptimal],
|
||||||
true,
|
true,
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
&[
|
&[(
|
||||||
(
|
|
||||||
"你好世界",
|
|
||||||
"你好",
|
|
||||||
&[0, 1],
|
|
||||||
BONUS_BOUNDARY_WHITE * (BONUS_FIRST_CHAR_MULTIPLIER + 1),
|
|
||||||
),
|
|
||||||
(
|
|
||||||
"你好世界",
|
"你好世界",
|
||||||
"你世",
|
"你世",
|
||||||
&[0, 2],
|
&[0, 2],
|
||||||
BONUS_BOUNDARY_WHITE * BONUS_FIRST_CHAR_MULTIPLIER - PENALTY_GAP_START,
|
BONUS_BOUNDARY_WHITE * BONUS_FIRST_CHAR_MULTIPLIER - PENALTY_GAP_START,
|
||||||
),
|
)],
|
||||||
],
|
|
||||||
);
|
);
|
||||||
assert_not_matches(
|
assert_not_matches(
|
||||||
false,
|
false,
|
||||||
|
Loading…
Reference in New Issue
Block a user