Accept all-caps possessives in spell check (#8628)

Found while testing crates/text/src/spell.rs:91 (Dictionary::check)

Co-authored-by: Claude Haiku 5.5 <noreply@anthropic.com>
This commit is contained in:
NetterSilver
2026-10-23 17:40:22 -04:00
committed by GitHub
co-authored by Claude Haiku 5.5
parent 4092fe79c9
commit c1158f92e8
+10 -1
View File
@@ -88,7 +88,7 @@ impl Dictionary {
/// Whether `word` is spelled correctly (also accepting `user` words, compared without case).
pub fn check(&self, word: &str, user: &HashSet<String>) -> bool {
let w = normalize(word);
let w = w.strip_suffix("'s").filter(|b| !b.is_empty()).unwrap_or(&w);
let w = w.strip_suffix("'s").or_else(|| w.strip_suffix("'S")).filter(|b| !b.is_empty()).unwrap_or(&w);
let w = w.trim_matches('\'');
if w.is_empty() || w.chars().any(|c| c.is_numeric()) || !w.chars().any(char::is_alphabetic) {
return true;
@@ -258,6 +258,15 @@ mod tests {
HashSet::new()
}
#[test]
fn all_caps_possessive_is_accepted() {
let d = Dictionary::english();
for w in ["MOTHER'S", "MONDAY'S", "Mother's", "mother's", "MOTHER’S"] {
assert!(d.check(w, &none()), "{w}");
}
assert!(!d.check("MOTHER'SX", &none()));
}
#[test]
fn bundled_dictionary_loads() {
let d = Dictionary::english();