Skip to content

Commit

Permalink
suggester: Fix subslice in try_rep_suggestion
Browse files Browse the repository at this point in the history
The equivalent C++ ways subslicing to a _length_ of `j - i` and we want
to slice _to_ j.
  • Loading branch information
the-mikedavis committed Nov 9, 2024
1 parent d23a934 commit 7a3bf34
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/suggester.rs
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ impl<'a, S: BuildHasher> Suggester<'a, S> {
};
let mut i = 0;
loop {
let part = &word[i..j - i];
let part = &word[i..j];
if self
.checker
.check_word(
Expand All @@ -433,10 +433,10 @@ impl<'a, S: BuildHasher> Suggester<'a, S> {
return;
}
i = j + 1;
let Some(idx) = word[i..].find(' ') else {
break;
};
j = idx + i;
match word[i..].find(' ') {
Some(idx) => j = i + idx,
None => break,
}
}

out.push(String::from(word));
Expand Down

0 comments on commit 7a3bf34

Please sign in to comment.