Skip to content

Offline, privacy-first grammar checker. Fast, open-source, Rust-powered

fix(core): `RepeatedWords` now detects repeated `and` tokens

Elijah Potter38b188374c2a
diff --git a/harper-core/src/linting/repeated_words.rs b/harper-core/src/linting/repeated_words.rs
index 068e6053d..61dd1bc24 100644
--- a/harper-core/src/linting/repeated_words.rs
+++ b/harper-core/src/linting/repeated_words.rs
@@ -13,12 +13,20 @@ pub struct RepeatedWords {
impl RepeatedWords {
pub fn new() -> Self {
Self {
- special_cases: vec![smallvec!['i', 's'], smallvec!['a']],
+ special_cases: vec![
+ smallvec!['i', 's'],
+ smallvec!['a'],
+ smallvec!['a', 'n', 'd'],
+ ],
}
}
fn is_special_case(&self, chars: &[char]) -> bool {
- self.special_cases.iter().any(|v| v.as_slice() == chars)
+ let lower = chars.to_lower();
+
+ self.special_cases
+ .iter()
+ .any(|v| v.as_slice() == lower.as_slice())
}
}
@@ -113,4 +121,13 @@ mod tests {
"This is a test",
);
}
+
+ #[test]
+ fn double_and() {
+ assert_suggestion_result(
+ "And and this is also a test",
+ RepeatedWords::default(),
+ "And this is also a test",
+ );
+ }
}