Skip to content

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

fix(core): allow erroneous `shift` usage in spellcheck (#1166)

Elijah Pottera7fa71adceb0
diff --git a/harper-core/src/linting/spell_check.rs b/harper-core/src/linting/spell_check.rs
index 22c32e815..85d4f86ce 100644
--- a/harper-core/src/linting/spell_check.rs
+++ b/harper-core/src/linting/spell_check.rs
@@ -295,7 +295,16 @@ mod tests {
);
}
- // Unit tests for specific spell check corrections
+ #[test]
+ fn abandonware_correction() {
+ assert_suggestion_result(
+ "abanonedware",
+ SpellCheck::new(FstDictionary::curated(), Dialect::Australian),
+ "abandonware",
+ );
+ }
+
+ // Unit tests for specific spellcheck corrections
#[test]
fn corrects_abandonedware_1131_1166() {
diff --git a/harper-core/src/spell/mod.rs b/harper-core/src/spell/mod.rs
index dd96db310..a977c5320 100644
--- a/harper-core/src/spell/mod.rs
+++ b/harper-core/src/spell/mod.rs
@@ -38,7 +38,11 @@ fn score_suggestion(misspelled_word: &[char], sug: &FuzzyMatchResult) -> i32 {
let mut score = sug.edit_distance as i32 * 10;
// People are much less likely to mistype the first letter.
- if misspelled_word.first().unwrap() == sug.word.first().unwrap() {
+ if misspelled_word
+ .first()
+ .unwrap()
+ .eq_ignore_ascii_case(sug.word.first().unwrap())
+ {
score -= 10;
}