Skip to content

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

fix: solve part 1. or #1298 by making "that" a special case (#1302)

Andrew Dunbare2c625c304de
diff --git a/harper-core/src/linting/nominal_wants.rs b/harper-core/src/linting/nominal_wants.rs
index 06a7f3ca4..5dcee5280 100644
--- a/harper-core/src/linting/nominal_wants.rs
+++ b/harper-core/src/linting/nominal_wants.rs
@@ -11,9 +11,21 @@ pub struct NominalWants {
impl Default for NominalWants {
fn default() -> Self {
+ // "That" can act as two kinds of pronoun: demonstrative and relative.
+ // As a demonstrative pronoun, it's third person singular.
+ // As a relative pronoun, it's behaves as any person:
+ // I am the one that wants to. He is the one that wants to.
+ fn is_applicable_pronoun(tok: &Token, src: &[char]) -> bool {
+ if tok.kind.is_pronoun() {
+ tok.span.get_content_string(src).to_lowercase() != "that"
+ } else {
+ false
+ }
+ }
+
let miss = WordSet::new(&["wont", "wonts", "want", "wants"]);
let pattern = SequencePattern::default()
- .then_pronoun()
+ .then(is_applicable_pronoun)
.then_whitespace()
.then(miss);
Self {
@@ -133,4 +145,13 @@ mod tests {
fn ignores_correct_usage_he() {
assert_lint_count("He wants to help.", NominalWants::default(), 0);
}
+
+ #[test]
+ fn ignores_correct_usage_that_1298() {
+ assert_lint_count(
+ "The projects that want to take it seriously are the best.",
+ NominalWants::default(),
+ 0,
+ );
+ }
}