Skip to content

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

feat: to to -> to do (#3294)

Cyncrovee2478421dd957
diff --git a/harper-core/default_config.json b/harper-core/default_config.json
index 44dd999c7..e20c6aa6b 100644
--- a/harper-core/default_config.json
+++ b/harper-core/default_config.json
@@ -5591,6 +5591,13 @@
"state": true,
"label": "Fond On"
}
+ },
+ {
+ "Bool": {
+ "name": "ToTo",
+ "state": true,
+ "label": "To To"
+ }
}
]
}
diff --git a/harper-core/src/linting/phrase_set_corrections/mod.rs b/harper-core/src/linting/phrase_set_corrections/mod.rs
index aab872ef9..97f00b3c9 100644
--- a/harper-core/src/linting/phrase_set_corrections/mod.rs
+++ b/harper-core/src/linting/phrase_set_corrections/mod.rs
@@ -1033,7 +1033,16 @@ pub fn lint_group() -> LintGroup {
"`Worse` is for comparing and `worst` is for the extreme case.",
"Corrects `worse` and `worst` used in contexts where the other belongs.",
LintKind::Agreement
- )
+ ),
+ "ToTo" => (
+ &[
+ (&["to to"], &["to do"]),
+ (&["to-to"], &["to-do"]),
+ ],
+ "Did you mean to write `do` instead of a second `to`?",
+ "Corrects `to to` to `to do` and `to-to` to `to-do`, as they may be typos.",
+ LintKind::Typo
+ ),
});
group.set_all_rules_to(Some(true));
diff --git a/harper-core/src/linting/phrase_set_corrections/tests.rs b/harper-core/src/linting/phrase_set_corrections/tests.rs
index ad2b307fc..f8431d7ff 100644
--- a/harper-core/src/linting/phrase_set_corrections/tests.rs
+++ b/harper-core/src/linting/phrase_set_corrections/tests.rs
@@ -3902,3 +3902,23 @@ fn detect_making_them_worst_atomic() {
"As for the last part about Apple deliberately making them worse in order for us to buy the 3s",
);
}
+
+// -to to-
+#[test]
+fn corrects_to_to() {
+ assert_suggestion_result(
+ "I need to add that to my to to list first.",
+ lint_group(),
+ "I need to add that to my to do list first.",
+ );
+}
+
+// -to-to-
+#[test]
+fn corrects_to_to_with_hyphen() {
+ assert_suggestion_result(
+ "I need to add that to my to-to list first.",
+ lint_group(),
+ "I need to add that to my to-do list first.",
+ );
+}