Skip to content

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

feat: if only there was→if only there were, etc. (#2823)

Andrew Dunbar0535e7855478
diff --git a/harper-core/src/linting/phrase_set_corrections/mod.rs b/harper-core/src/linting/phrase_set_corrections/mod.rs
index 43b716996..290c2f7e3 100644
--- a/harper-core/src/linting/phrase_set_corrections/mod.rs
+++ b/harper-core/src/linting/phrase_set_corrections/mod.rs
@@ -418,6 +418,23 @@ pub fn lint_group() -> LintGroup {
"Corrects `scape goat` to `scapegoat`, which is the proper term for a person blamed for others' failures.",
LintKind::Eggcorn
),
+ "SubjunctiveWasToWere" => (
+ &[
+ ("if only there was", "if only there were"),
+ ("if only i was", "if only i were"),
+ ("if only he was", "if only he were"),
+ ("if only she was", "if only she were"),
+ ("if only it was", "if only it were"),
+ ("i wish there was", "i wish there were"),
+ ("i wish i was", "i wish i were"),
+ ("i wish he was", "i wish he were"),
+ ("i wish she was", "i wish she were"),
+ ("i wish it was", "i wish it were")
+ ],
+ "Use the subjunctive mood with `if only` or `I wish`. The correct form is `were`, not `was`.",
+ "Ensures proper use of the subjunctive mood in counterfactual conditional statements starting with `if only` or `I wish`.",
+ LintKind::Grammar
+ ),
"SeamToSeem" => (
&[
("seam to be", "seem to be"),
diff --git a/harper-core/src/linting/phrase_set_corrections/tests.rs b/harper-core/src/linting/phrase_set_corrections/tests.rs
index 5e96fc443..5e27e83d9 100644
--- a/harper-core/src/linting/phrase_set_corrections/tests.rs
+++ b/harper-core/src/linting/phrase_set_corrections/tests.rs
@@ -762,6 +762,7 @@ fn correct_honed_in_on() {
// InDetail
// -in details-
+#[test]
fn in_detail_atomic() {
assert_suggestion_result("in details", lint_group(), "in detail");
}
@@ -1096,6 +1097,108 @@ fn fix_escape_goats() {
);
}
+// SubjunctiveWasToWere
+
+// -if only there was-
+#[test]
+fn if_only_there_was() {
+ assert_suggestion_result(
+ "if only there was an endpoint do to so",
+ lint_group(),
+ "if only there were an endpoint do to so",
+ );
+}
+
+// -if only I-
+#[test]
+fn if_only_i_was() {
+ assert_suggestion_result(
+ "Oh If only I was that clever !!",
+ lint_group(),
+ "Oh If only I were that clever !!",
+ );
+}
+
+// -if only he-
+#[test]
+fn if_only_he_was() {
+ assert_suggestion_result(
+ "If only he was kind enough to attempt to contact me in private first",
+ lint_group(),
+ "If only he were kind enough to attempt to contact me in private first",
+ );
+}
+
+// -if only she-
+#[test]
+fn if_only_she_was() {
+ assert_suggestion_result(
+ "If only she was right.",
+ lint_group(),
+ "If only she were right.",
+ );
+}
+
+// -it-
+#[test]
+fn if_only_it_was() {
+ assert_suggestion_result(
+ "if only it was accessible via USB connection - hint hint",
+ lint_group(),
+ "if only it were accessible via USB connection - hint hint",
+ );
+}
+
+// -I wish there was-
+#[test]
+fn i_wish_there_was() {
+ assert_suggestion_result(
+ "I wish there was a keyboard shortcut or something that was \"bring back the suggestion you just made in the last 3 seconds\".",
+ lint_group(),
+ "I wish there were a keyboard shortcut or something that was \"bring back the suggestion you just made in the last 3 seconds\".",
+ );
+}
+
+// -I wish I was-
+#[test]
+fn i_wish_i_was() {
+ assert_suggestion_result(
+ "I wish I was as smart as I think I am.",
+ lint_group(),
+ "I wish I were as smart as I think I am.",
+ );
+}
+
+// -I wish he was-
+#[test]
+fn i_wish_he_was() {
+ assert_suggestion_result(
+ "However I wish he was that smart about ARM chips present in the current mobile devices.",
+ lint_group(),
+ "However I wish he were that smart about ARM chips present in the current mobile devices.",
+ );
+}
+
+// -I wish she was-
+#[test]
+fn i_wish_she_was() {
+ assert_suggestion_result(
+ "I wish she was more accepting of her own interests.",
+ lint_group(),
+ "I wish she were more accepting of her own interests.",
+ );
+}
+
+// -I wish it was-
+#[test]
+fn i_wish_it_was() {
+ assert_suggestion_result(
+ "but I wish it was more friendly to existing ecosystems",
+ lint_group(),
+ "but I wish it were more friendly to existing ecosystems",
+ );
+}
+
// SeamToSeem
//-seam to be-