From ff8fce5fb62bc5cc63594cae18c38717a256497b Mon Sep 17 00:00:00 2001 From: Ed Page Date: Fri, 25 Oct 2019 14:58:08 -0600 Subject: [PATCH] fix: Don't check words if ident gets a hit --- typos/src/checks.rs | 54 +++++++++++++++++++++++---------------------- 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/typos/src/checks.rs b/typos/src/checks.rs index 02d8f19..618ab2f 100644 --- a/typos/src/checks.rs +++ b/typos/src/checks.rs @@ -88,17 +88,18 @@ impl<'d, 'p> Checks<'d, 'p> { }; report(msg.into()); typos_found = true; - } - for word in ident.split() { - if let Some(correction) = self.dictionary.correct_word(word) { - let msg = report::FilenameCorrection { - path, - typo: word.token(), - correction, - non_exhaustive: (), - }; - report(msg.into()); - typos_found = true; + } else { + for word in ident.split() { + if let Some(correction) = self.dictionary.correct_word(word) { + let msg = report::FilenameCorrection { + path, + typo: word.token(), + correction, + non_exhaustive: (), + }; + report(msg.into()); + typos_found = true; + } } } } @@ -145,21 +146,22 @@ impl<'d, 'p> Checks<'d, 'p> { }; typos_found = true; report(msg.into()); - } - for word in ident.split() { - if let Some(correction) = self.dictionary.correct_word(word) { - let col_num = word.offset(); - let msg = report::Correction { - path, - line, - line_num, - col_num, - typo: word.token(), - correction, - non_exhaustive: (), - }; - typos_found = true; - report(msg.into()); + } else { + for word in ident.split() { + if let Some(correction) = self.dictionary.correct_word(word) { + let col_num = word.offset(); + let msg = report::Correction { + path, + line, + line_num, + col_num, + typo: word.token(), + correction, + non_exhaustive: (), + }; + typos_found = true; + report(msg.into()); + } } } }