Skip to content

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

style(fst-dict): add comments explaining the dedup in FstDictionary

Grant Lemons40d80abf468d
diff --git a/harper-core/src/spell/fst_dictionary.rs b/harper-core/src/spell/fst_dictionary.rs
index d2c006e14..7702fdb0b 100644
--- a/harper-core/src/spell/fst_dictionary.rs
+++ b/harper-core/src/spell/fst_dictionary.rs
@@ -163,9 +163,10 @@ impl Dictionary for FstDictionary {
&mut word_indexes_lowercase_stream,
&dfa_lowercase,
))
- // Sort by edit distance
+ // Remove duplicates caused by checking exact and lowercase
.sorted_unstable_by_key(|a| a.0)
.dedup_by(|a, b| a.0 == b.0)
+ // Sort by edit distance
.sorted_unstable_by_key(|a| a.1)
.take(max_results)
.map(|(index, edit_distance)| {