Skip to content

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

fix: don't flag "defo" (#4390)

Andrew Dunbarea8614e3d9c2
diff --git a/harper-core/src/linting/wrong_negative.rs b/harper-core/src/linting/wrong_negative.rs
index e6f86dd8f..35b1a8fa2 100644
--- a/harper-core/src/linting/wrong_negative.rs
+++ b/harper-core/src/linting/wrong_negative.rs
@@ -12,6 +12,7 @@ fn looks_negative_but_oov(token: &Token, source: &[char]) -> bool {
&& token
.get_ch(source)
.starts_with_any_ignore_ascii_case_str(NEGATIVE_PREFIXES)
+ && !token.get_ch(source).eq_ch(&['d', 'e', 'f', 'o'])
}
pub struct WrongNegative<D: Dictionary + 'static> {
@@ -95,7 +96,10 @@ mod tests {
use crate::{
Dialect,
document::Document,
- linting::{LintGroup, Linter, spell_check, tests::assert_suggestion_result},
+ linting::{
+ LintGroup, Linter, spell_check,
+ tests::{assert_no_lints, assert_suggestion_result},
+ },
remove_overlaps,
spell::FstDictionary,
};
@@ -167,4 +171,12 @@ mod tests {
"Could this be the negative word you intended?"
);
}
+
+ #[test]
+ fn dont_flag_defo() {
+ assert_no_lints(
+ "I defo used MSVC back then too",
+ WrongNegative::new(FstDictionary::curated()),
+ );
+ }
}