mirror of
https://github.com/crate-ci/typos.git
synced 2024-11-25 18:41:05 -05:00
refactor(cli): Make room for ident correction
This commit is contained in:
parent
b798780a13
commit
fd6873b6e0
1 changed files with 9 additions and 3 deletions
|
@ -32,7 +32,7 @@ impl BuiltIn {
|
||||||
|
|
||||||
let word = word_token.token();
|
let word = word_token.token();
|
||||||
let word_case = unicase::UniCase::new(word);
|
let word_case = unicase::UniCase::new(word);
|
||||||
let mut corrections = if let Some(corrections) = self.correct_with_dict(word_case) {
|
let mut corrections = if let Some(corrections) = self.correct_word_with_dict(word_case) {
|
||||||
if corrections.is_empty() {
|
if corrections.is_empty() {
|
||||||
Status::Invalid
|
Status::Invalid
|
||||||
} else {
|
} else {
|
||||||
|
@ -51,14 +51,20 @@ impl BuiltIn {
|
||||||
#[cfg(feature = "dict")]
|
#[cfg(feature = "dict")]
|
||||||
impl BuiltIn {
|
impl BuiltIn {
|
||||||
// Not using `Status` to avoid the allocations
|
// Not using `Status` to avoid the allocations
|
||||||
fn correct_with_dict(&self, word: unicase::UniCase<&str>) -> Option<&'static [&'static str]> {
|
fn correct_word_with_dict(
|
||||||
|
&self,
|
||||||
|
word: unicase::UniCase<&str>,
|
||||||
|
) -> Option<&'static [&'static str]> {
|
||||||
typos_dict::WORD_TRIE.find(&word).copied()
|
typos_dict::WORD_TRIE.find(&word).copied()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(feature = "dict"))]
|
#[cfg(not(feature = "dict"))]
|
||||||
impl BuiltIn {
|
impl BuiltIn {
|
||||||
fn correct_with_dict(&self, _word: unicase::UniCase<&str>) -> Option<&'static [&'static str]> {
|
fn correct_word_with_dict(
|
||||||
|
&self,
|
||||||
|
_word: unicase::UniCase<&str>,
|
||||||
|
) -> Option<&'static [&'static str]> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue