From e171e0830be0a9561665549a68350e79ade4ec46 Mon Sep 17 00:00:00 2001 From: V1dalTheAbidal <97257872+V1dalTheAbidal@users.noreply.github.com> Date: Wed, 11 Nov 2026 22:00:19 +0200 Subject: [PATCH] Greek keyboard: a word folds only when the layout types it MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `greek_fold` upper-cased the word with Unicode's rules before it read the keys. Upper-casing turns some characters the layout does not type into Greek or ASCII letters: the micro sign into Μ, the long s into S, the sharp s into SS, an alpha with an iota subscript into ΑΙ, the theta symbol into Θ. A stored name with such a character then counted as a spelling of a Greek word, although `latin_keys` does not read it. The fold is now the word's keys with the final sigma read as the letter sigma, so a word folds exactly when `latin_keys` reads it. Where the old fold and the new one both exist they are the same string. Test: five such pairs are not one word. It fails without the change. --- crates/engine/src/keyboard.rs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/crates/engine/src/keyboard.rs b/crates/engine/src/keyboard.rs index b6f306601..616aa53b8 100644 --- a/crates/engine/src/keyboard.rs +++ b/crates/engine/src/keyboard.rs @@ -81,9 +81,10 @@ pub fn latin_keys(word: &str) -> Option { } /// `word` with its case, accents and final sigma folded away, when it is Greek-layout typing: every -/// spelling of one Greek word gives the same string. +/// spelling of one Greek word gives the same string. It is the word's keys, with the final sigma +/// read as the letter sigma instead of the W key. pub fn greek_fold(word: &str) -> Option { - latin_keys(&word.to_uppercase()) + latin_keys(&word.replace('ς', "σ")) } /// Whether `a` and `b` are one Greek word, whatever their case, accents or final sigma. @@ -116,6 +117,16 @@ mod tests { } } + /// A character the layout does not type is never taken for the Greek letter Unicode upper-cases + /// it to: the micro sign is not μ, the long s and the sharp s are not σ, an alpha with an iota + /// subscript is not αι, the theta symbol is not θ. + #[test] + fn a_character_the_layout_does_not_type_is_no_spelling_of_a_greek_letter() { + let pairs = [("\u{b5}", "μ"), ("Λ\u{17f}", "ΛΣ"), ("Λ\u{df}", "ΛΣΣ"), ("\u{1fb3}", "αι"), ("\u{3d1}", "θ")]; + let same: Vec<_> = pairs.iter().filter(|(a, b)| same_greek_word(a, b) || same_greek_word(b, a)).collect(); + assert!(same.is_empty(), "{same:?}"); + } + /// Greek-layout typing reads as its Latin keys: plain, accented and decomposed letters, the Q /// and W keys, ASCII prefixes. #[test]