diff --git a/harper-core/src/linting/spell_check.rs b/harper-core/src/linting/spell_check.rs index 715cc9a9b0..361bcf9cf4 100644 --- a/harper-core/src/linting/spell_check.rs +++ b/harper-core/src/linting/spell_check.rs @@ -3,8 +3,8 @@ use std::num::NonZero; use lru::LruCache; use smallvec::ToSmallVec; -use super::Suggestion; use super::{Lint, LintKind, Linter}; +use super::{Suggestion, informal_laughter::is_informal_laughter}; use crate::document::Document; use crate::spell::{Dictionary, suggest_correct_spelling}; use crate::{CharString, CharStringExt, Dialect, TokenStringExt}; @@ -73,6 +73,10 @@ impl Linter for SpellCheck { for word in document.iter_words() { let word_chars = document.get_span_content(&word.span); + if is_informal_laughter(word_chars) { + continue; + } + if let Some(metadata) = word.kind.as_word().unwrap() && metadata.dialects.is_dialect_enabled(self.dialect) && (self.dictionary.contains_exact_word(word_chars) @@ -150,6 +154,24 @@ mod tests { }; use crate::{DictWordMetadata, Document}; + #[test] + fn athough_suggests_although() { + assert_suggestion_result( + "athough it was late, we continued.", + SpellCheck::new(FstDictionary::curated(), Dialect::American), + "although it was late, we continued.", + ); + } + + #[test] + fn athough_suggests_although_capitalized() { + assert_suggestion_result( + "Athough it was late, we continued.", + SpellCheck::new(FstDictionary::curated(), Dialect::American), + "Although it was late, we continued.", + ); + } + // Capitalization tests #[test] @@ -1007,4 +1029,14 @@ mod tests { "children's", ); } + + #[test] + fn allows_informal_laughter() { + for source in ["hahah", "hahaha", "hahahah", "Hahahah", "HAHAHA"] { + assert_no_lints( + source, + SpellCheck::new(FstDictionary::curated(), Dialect::American), + ); + } + } }