diff options
author | Federico Stra <stra.federico@gmail.com> | 2022-09-12 11:50:16 +0200 |
---|---|---|
committer | Federico Stra <stra.federico@gmail.com> | 2022-09-12 11:50:16 +0200 |
commit | c527d37b01dbec971e82bdfed9fbb2a2172d6b3b (patch) | |
tree | 923dedc8c32acfb4ad77474767e00b1223ef046b /src/pattern | |
parent | 3474c157ec41cc9fc17b4923903737faddcc87d8 (diff) |
bugfix: fix `TokPattern::find_ranges` to solve #504
Diffstat (limited to 'src/pattern')
-rw-r--r-- | src/pattern/tok_pattern.rs | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/pattern/tok_pattern.rs b/src/pattern/tok_pattern.rs index 0aef5b7..83c7744 100644 --- a/src/pattern/tok_pattern.rs +++ b/src/pattern/tok_pattern.rs @@ -80,11 +80,11 @@ impl TokPattern { /// return either None (no match) or a vec whose size is the number /// of tokens fn find_ranges(&self, candidate: &str) -> Option<Vec<Range<usize>>> { - if candidate.len() < self.sum_len || self.sum_len == 0 { - return None; - } let mut cand_chars: CandChars = SmallVec::with_capacity(candidate.len()); cand_chars.extend(candidate.chars().map(secular::lower_lay_char)); + if cand_chars.len() < self.sum_len || self.sum_len == 0 { + return None; + } // we first look for the first tok, it's simpler let first_tok = &self.toks[0]; let l = first_tok.len(); @@ -234,6 +234,7 @@ mod tok_pattern_tests { check_match("mi", "a", false); check_match("mi", "π", false); check_match("mi", "miaou/a", true); + check_match("imm", "😍", false); } #[test] |