mirror of
https://github.com/crate-ci/typos.git
synced 2024-11-25 10:31:02 -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_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() {
|
||||
Status::Invalid
|
||||
} else {
|
||||
|
@ -51,14 +51,20 @@ impl BuiltIn {
|
|||
#[cfg(feature = "dict")]
|
||||
impl BuiltIn {
|
||||
// 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()
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "dict"))]
|
||||
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
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue