mirror of
https://github.com/crate-ci/typos.git
synced 2024-11-29 04:21:06 -05:00
parent
86c4c9fb4a
commit
55d802d0ef
2 changed files with 11 additions and 8 deletions
|
@ -284,27 +284,30 @@ impl<'i, 'w, D: typos::Dictionary> typos::Dictionary for Override<'i, 'w, D> {
|
||||||
self.inner.correct_ident(ident)
|
self.inner.correct_ident(ident)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn correct_word<'s>(&'s self, word: typos::tokens::Word<'_>) -> Option<Status<'s>> {
|
fn correct_word<'s>(&'s self, word_token: typos::tokens::Word<'_>) -> Option<Status<'s>> {
|
||||||
if word.case() == typos::tokens::Case::None {
|
if word_token.case() == typos::tokens::Case::None {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
for ignored in &self.ignored_words {
|
for ignored in &self.ignored_words {
|
||||||
if ignored.is_match(word.token()) {
|
if ignored.is_match(word_token.token()) {
|
||||||
return Some(Status::Valid);
|
return Some(Status::Valid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Skip hashing if we can
|
// Skip hashing if we can
|
||||||
if !self.words.is_empty() {
|
if !self.words.is_empty() {
|
||||||
let w = UniCase::new(word.token());
|
let w = UniCase::new(word_token.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`
|
||||||
if let Some(status) = self.words.get(&w).cloned() {
|
if let Some(mut corrections) = self.words.get(&w).cloned() {
|
||||||
return Some(status);
|
for s in corrections.corrections_mut() {
|
||||||
|
case_correct(s, word_token.case())
|
||||||
|
}
|
||||||
|
return Some(corrections);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.inner.correct_word(word)
|
self.inner.correct_word(word_token)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ args = ""
|
||||||
status.code = 2
|
status.code = 2
|
||||||
stdin = ""
|
stdin = ""
|
||||||
stdout = """
|
stdout = """
|
||||||
error: `Trailling` should be `trailing`
|
error: `Trailling` should be `Trailing`
|
||||||
--> ./file.txt:1:26
|
--> ./file.txt:1:26
|
||||||
|
|
|
|
||||||
1 | public function noErrorOnTraillingSemicolonAndWhitespace(Connection $connection)
|
1 | public function noErrorOnTraillingSemicolonAndWhitespace(Connection $connection)
|
||||||
|
|
Loading…
Reference in a new issue