Skip to content

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

Merge pull request #713 from Automattic/fix-spell-problems

Elijah Potter6b8b3510ecfc
diff --cc harper-core/src/linting/compound_nouns/general_compound_nouns.rs
index 00c96d2c9,0a24eedf1..1acb76b86
--- a/harper-core/src/linting/compound_nouns/general_compound_nouns.rs
+++ b/harper-core/src/linting/compound_nouns/general_compound_nouns.rs
@@@ -56,17 -56,18 +56,17 @@@ impl PatternLinter for GeneralCompoundN
self.pattern.as_ref()
}
- fn match_to_lint(&self, matched_tokens: &[Token], source: &[char]) -> Lint {
- let span = matched_tokens.span().unwrap();
+ fn match_to_lint(&self, matched_tokens: &[Token], source: &[char]) -> Option<Lint> {
+ let span = matched_tokens.span()?;
let orig = span.get_content(source);
// If the pattern matched, this will not return `None`.
- let word = self
- .split_pattern
- .get_merged_word(matched_tokens[0], matched_tokens[2], source)
- .unwrap();
+ let word =
+ self.split_pattern
+ .get_merged_word(matched_tokens[0], matched_tokens[2], source)?;
- Lint {
+ Some(Lint {
span,
- lint_kind: LintKind::Spelling,
+ lint_kind: LintKind::WordChoice,
suggestions: vec![Suggestion::replace_with_match_case(word.to_vec(), orig)],
message: format!(
"Did you mean the closed compound noun “{}”?",
diff --cc harper-core/src/linting/compound_nouns/implied_ownership_compound_nouns.rs
index af67e5abf,14395a541..fbf13ac51
--- a/harper-core/src/linting/compound_nouns/implied_ownership_compound_nouns.rs
+++ b/harper-core/src/linting/compound_nouns/implied_ownership_compound_nouns.rs
@@@ -36,16 -36,17 +36,16 @@@ impl PatternLinter for ImpliedOwnership
self.pattern.as_ref()
}
- fn match_to_lint(&self, matched_tokens: &[Token], source: &[char]) -> Lint {
- let span = matched_tokens[2..].span().unwrap();
+ fn match_to_lint(&self, matched_tokens: &[Token], source: &[char]) -> Option<Lint> {
+ let span = matched_tokens[2..].span()?;
// If the pattern matched, this will not return `None`.
- let word = self
- .split_pattern
- .get_merged_word(matched_tokens[2], matched_tokens[4], source)
- .unwrap();
+ let word =
+ self.split_pattern
+ .get_merged_word(matched_tokens[2], matched_tokens[4], source)?;
- Lint {
+ Some(Lint {
span,
- lint_kind: LintKind::Spelling,
+ lint_kind: LintKind::WordChoice,
suggestions: vec![Suggestion::ReplaceWith(word.to_vec())],
message: format!(
"The possessive noun implies ownership of the closed compound noun “{}”.",