Skip to content

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

fix(core): remove bad matcher entries

Elijah Potterf02b9e9523e8
diff --git a/harper-core/affixes.json b/harper-core/affixes.json
index 5ef61d7d6..ba6788405 100644
--- a/harper-core/affixes.json
+++ b/harper-core/affixes.json
@@ -53,7 +53,10 @@
"condition": "."
}
],
- "adds_metadata": {},
+ "adds_metadata": {
+ "adjective": {},
+ "adverb": {}
+ },
"gifts_metadata": {}
},
"U": {
diff --git a/harper-core/src/linting/matcher.rs b/harper-core/src/linting/matcher.rs
index e6b8a73fe..95fa6d512 100644
--- a/harper-core/src/linting/matcher.rs
+++ b/harper-core/src/linting/matcher.rs
@@ -121,15 +121,6 @@ impl Matcher {
"wordlist" => "word list"
});
- // mixing up than/then in context
- triggers.extend(pt! {
- "then","her" => "than her",
- "then","hers" => "than hers",
- "then","him" => "than him",
- "then","his" => "than his",
- "then","last","week" => "than last week"
- });
-
// not a perfect fit for any of the other categories
triggers.extend(pt! {
"performing","this" => "perform this",
diff --git a/harper-core/src/linting/then_than.rs b/harper-core/src/linting/then_than.rs
index 33487b036..146e62d0f 100644
--- a/harper-core/src/linting/then_than.rs
+++ b/harper-core/src/linting/then_than.rs
@@ -1,6 +1,5 @@
use super::{Lint, LintKind, PatternLinter};
use crate::Token;
-use crate::char_string::char_string;
use crate::linting::Suggestion;
use crate::patterns::{
All, AnyCapitalization, Invert, OwnedPatternExt, Pattern, SequencePattern, WordSet,
@@ -23,7 +22,7 @@ impl ThenThan {
.then_whitespace()
.then_any_capitalization_of("then")
.then_whitespace()
- .then(Invert::new(AnyCapitalization::new(char_string!("that")))),
+ .then(Invert::new(AnyCapitalization::of("that"))),
),
// Denotes exceptions to the rule.
Box::new(Invert::new(WordSet::new(&["back", "this", "so", "but"]))),
@@ -288,4 +287,49 @@ mod tests {
0,
);
}
+
+ #[test]
+ fn more_talented_then_her_issue_720() {
+ assert_suggestion_result(
+ "He was more talented then her at writing code.",
+ ThenThan::default(),
+ "He was more talented than her at writing code.",
+ );
+ }
+
+ #[test]
+ fn simpler_then_hers_issue_720() {
+ assert_suggestion_result(
+ "The design was simpler then hers in layout and color scheme.",
+ ThenThan::default(),
+ "The design was simpler than hers in layout and color scheme.",
+ );
+ }
+
+ #[test]
+ fn earlier_then_him_issue_720() {
+ assert_suggestion_result(
+ "We arrived earlier then him at the event.",
+ ThenThan::default(),
+ "We arrived earlier than him at the event.",
+ );
+ }
+
+ #[test]
+ fn more_robust_then_his_issue_720() {
+ assert_suggestion_result(
+ "This approach is more robust then his for handling edge cases.",
+ ThenThan::default(),
+ "This approach is more robust than his for handling edge cases.",
+ );
+ }
+
+ #[test]
+ fn patch_more_recently_then_last_week_issue_720() {
+ assert_suggestion_result(
+ "We submitted the patch more recently then last week, so they should have it already.",
+ ThenThan::default(),
+ "We submitted the patch more recently than last week, so they should have it already.",
+ );
+ }
}