diff options
author | Canop <cano.petrole@gmail.com> | 2021-05-11 17:28:59 +0200 |
---|---|---|
committer | Canop <cano.petrole@gmail.com> | 2021-05-11 17:36:06 +0200 |
commit | 289a08741ef5b375305b3bda84962b83dfc93ecd (patch) | |
tree | ae04a9ed1a4ef2c0fea13ecdaa080c33c46d63e5 /src/pattern | |
parent | e5aa1eb607470d7f3fffdbe0ba4c27ba9555700f (diff) |
fix max_nb_holes not checked in fuzzy patterns
Diffstat (limited to 'src/pattern')
-rw-r--r-- | src/pattern/fuzzy_pattern.rs | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/pattern/fuzzy_pattern.rs b/src/pattern/fuzzy_pattern.rs index d0adee0..90c07ec 100644 --- a/src/pattern/fuzzy_pattern.rs +++ b/src/pattern/fuzzy_pattern.rs @@ -60,7 +60,7 @@ impl FuzzyPattern { 2 => 1, 3 => 2, 4 => 2, - 5 => 3, + 5 => 2, 6 => 3, 7 => 3, 8 => 4, @@ -130,6 +130,9 @@ impl FuzzyPattern { } } } + if nb_holes > self.max_nb_holes { + return MatchSearchResult::None; + } let match_len = 1 + cand_idx - pos[0]; let mut score = BONUS_MATCH; score += BONUS_CANDIDATE_LENGTH * (cand_chars.len() as i32); |