Offline, privacy-first grammar checker. Fast, open-source, Rust-powered
feat(core): added more suggestion possibilities
Elijah Pottereec01234908a
diff --git a/harper-core/src/linting/lets_confusion/let_us_redundancy.rs b/harper-core/src/linting/lets_confusion/let_us_redundancy.rsindex b42c21e30..39fb32b34 100644--- a/harper-core/src/linting/lets_confusion/let_us_redundancy.rs+++ b/harper-core/src/linting/lets_confusion/let_us_redundancy.rs@@ -26,11 +26,27 @@ impl PatternLinter for LetUsRedundancy {self.pattern.as_ref()}- fn match_to_lint(&self, matched_tokens: &[Token], _source: &[char]) -> Lint {+ fn match_to_lint(&self, matched_tokens: &[Token], source: &[char]) -> Lint {+ let template = matched_tokens.span().unwrap().get_content(source);+ let pronoun = matched_tokens+ .last()+ .unwrap()+ .span+ .get_content_string(source);+Lint {- span: matched_tokens[1..3].span().unwrap(),+ span: matched_tokens.span().unwrap(),lint_kind: LintKind::Repetition,- suggestions: vec![Suggestion::Remove],+ suggestions: vec![+ Suggestion::replace_with_match_case(+ format!("lets {pronoun}").chars().collect(),+ template,+ ),+ Suggestion::replace_with_match_case(+ "let's".to_string().chars().collect(),+ template,+ ),+ ],message: "`let's` stands for `let us`, so including another pronoun is redundant.".to_owned(),priority: 31,diff --git a/harper-core/src/linting/lets_confusion/mod.rs b/harper-core/src/linting/lets_confusion/mod.rsindex d5e7498e3..e0f1425ab 100644--- a/harper-core/src/linting/lets_confusion/mod.rs+++ b/harper-core/src/linting/lets_confusion/mod.rs@@ -13,14 +13,23 @@ mod tests {use super::LetsConfusion;+ #[test]+ fn walking() {+ assert_suggestion_result(+ "The crutch let's him walk.",+ LetsConfusion::default(),+ "The crutch lets him walk.",+ );+ }+#[test]fn issue_426_us() {- assert_suggestion_result("let's us do", LetsConfusion::default(), "let's do");+ assert_suggestion_result("let's us do", LetsConfusion::default(), "lets us do");}#[test]fn issue_426_me() {- assert_suggestion_result("let's me do", LetsConfusion::default(), "let's do");+ assert_suggestion_result("let's me do", LetsConfusion::default(), "lets me do");}#[test]