Spelling: check all-caps candidates in capitals so KEEPCASE words are suggested

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Brandon ThomasandClaude Opus 5.5 committed 2026-10-30 15:57:45 -04:00
1 parent 6fbfea12a6
commit 1841ab75da
1 file changed
+8 -4
+8 -4
View File
@@ -400,7 +400,12 @@ impl Dictionary {
let mut out: Vec<String> = vec![];
let mut seen = HashSet::new();
let mut push = |s: String, out: &mut Vec<String>| {
if s != lower && seen.insert(s.to_lowercase()) && s.split(' ').all(|p| self.suggestible(p)) {
if s == lower {
return;
}
// Checked in capitals, so a KEEPCASE entry ("NASA") is offered for an all-caps word.
let s = if upper { s.to_uppercase() } else { s };
if seen.insert(s.to_lowercase()) && s.split(' ').all(|p| self.suggestible(p)) {
out.push(s);
}
};
@@ -444,9 +449,7 @@ impl Dictionary {
push(format!("{} {}", s(&w[..i]), s(&w[i..])), &mut out);
}
out.truncate(n);
if upper {
out = out.into_iter().map(|x| x.to_uppercase()).collect();
} else if cap {
if cap && !upper {
out = out.into_iter().map(|x| capitalise(&x)).collect();
}
out
@@ -851,6 +854,7 @@ SFX D Y 1\nSFX D 0 ed/S .\n";
let d = d();
assert!(d.suggest("SLDE", 5).contains(&"SLIDE".to_string()));
assert!(d.suggest("FOTO", 5).contains(&"PHOTO".to_string()));
assert!(d.suggest("NSSA", 5).contains(&"NASA".to_string()));
}
#[test]