mirror of
https://github.com/crate-ci/typos.git
synced 2024-12-23 16:12:25 -05:00
fix(dict): Ensure we fall through to built-in dict
This commit is contained in:
parent
36709b6f37
commit
482d320407
1 changed files with 4 additions and 6 deletions
10
src/dict.rs
10
src/dict.rs
|
@ -212,16 +212,14 @@ impl<'i, 'w, D: typos::Dictionary> typos::Dictionary for Override<'i, 'w, D> {
|
||||||
|
|
||||||
fn correct_word<'s, 't>(&'s self, word: typos::tokens::Word<'t>) -> Option<Status<'s>> {
|
fn correct_word<'s, 't>(&'s self, word: typos::tokens::Word<'t>) -> Option<Status<'s>> {
|
||||||
// Skip hashing if we can
|
// Skip hashing if we can
|
||||||
if !self.words.is_empty() {
|
let custom = if !self.words.is_empty() {
|
||||||
let w = UniCase::new(word.token());
|
let w = UniCase::new(word.token());
|
||||||
// HACK: couldn't figure out the lifetime issue with replacing `cloned` with `borrow`
|
// HACK: couldn't figure out the lifetime issue with replacing `cloned` with `borrow`
|
||||||
self.words
|
self.words.get(&w).cloned()
|
||||||
.get(&w)
|
|
||||||
.cloned()
|
|
||||||
.or_else(|| self.inner.correct_word(word))
|
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
};
|
||||||
|
custom.or_else(|| self.inner.correct_word(word))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue