Skip to content

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

Prioritized longer words in spellcheck

Elijah Potter2bbab4c8ac86
diff --git a/harper-core/src/linting/spell_check.rs b/harper-core/src/linting/spell_check.rs
index 63baaa03c..11b1d7886 100644
--- a/harper-core/src/linting/spell_check.rs
+++ b/harper-core/src/linting/spell_check.rs
@@ -26,7 +26,10 @@ impl Linter for SpellCheck {
continue;
}
- let possibilities = suggest_correct_spelling(word_chars, 3, 3, &self.dictionary);
+ let mut possibilities = suggest_correct_spelling(word_chars, 10, 3, &self.dictionary);
+
+ // People more likely to misspell words by omission, so show the longest words first.
+ possibilities.sort_by_key(|p| usize::MAX - p.len());
let suggestions = possibilities
.into_iter()