refactor(cli): Make room for ident correction

This commit is contained in:
Ed Page 2023-09-25 12:40:17 -05:00
parent b798780a13
commit fd6873b6e0

View file

@ -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
} }
} }