From ac06c87831992c59a5ad23affc44444dac140c7e Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 20 Oct 2026 16:50:41 +0800 Subject: [PATCH] Russian and Czech dictionaries are reported, not just checked (storytold/wordcraft#3226) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit installed_dictionaries() never included Russian or Czech at all, because neither crates/proof/src/ru nor crates/proof/src/cs had an installed_path() function for it to call (every other proofed Hunspell language — Polish, Portuguese, Italian, Croatian, Turkish, Indonesian — already did). File > Options > Proofing's dictionaries list iterates installed_dictionaries() directly, so Russian and Czech never showed up there at all, installed or not, matching the report. Added installed_path() to both modules, mirroring the existing pattern (crate::hunspell::find(NAMES).map(|(_, dic)| dic)), and added both to installed_dictionaries(). The actual spell-checking dispatch (is_correct_in_with) already routed Russian and Czech correctly — confirmed by installing the real system ru_RU Hunspell dictionary and checking it directly (ru::is_correct("молоко") true, ru::is_correct("малоко") false), so that part of the pipeline isn't what's broken. The reporter's other symptom (Russian text in the document not being checked at all) did not reproduce with the real dictionary installed; I could not pin that part down further without more specific repro details from their setup. Co-Authored-By: Claude Sonnet 5 --- crates/proof/src/cs/mod.rs | 7 +++++++ crates/proof/src/lib.rs | 13 +++++++++++++ crates/proof/src/ru/mod.rs | 7 +++++++ 3 files changed, 27 insertions(+) diff --git a/crates/proof/src/cs/mod.rs b/crates/proof/src/cs/mod.rs index 1d4b92f6..3531745f 100644 --- a/crates/proof/src/cs/mod.rs +++ b/crates/proof/src/cs/mod.rs @@ -57,6 +57,13 @@ pub fn reload_dictionary() { *DICT.write().unwrap_or_else(|e| e.into_inner()) = None; } +/// The `.dic` file of the installed Czech dictionary, searching the dictionaries folder and +/// the system locations now (File › Options › Proofing shows it, #3226); `None` when there is +/// none. A dictionary given with [`install_dictionary`] has no file and isn't reported. +pub fn installed_path() -> Option { + crate::hunspell::find(NAMES).map(|(_, dic)| dic) +} + /// Is a Czech dictionary available (spelling is checked)? pub fn has_dictionary() -> bool { !dictionary().is_empty() diff --git a/crates/proof/src/lib.rs b/crates/proof/src/lib.rs index 5afa42d7..0a2df0b7 100644 --- a/crates/proof/src/lib.rs +++ b/crates/proof/src/lib.rs @@ -163,6 +163,8 @@ pub fn installed_dictionaries() -> Vec<(ProofLang, Option)> (ProofLang::It, it::installed_path()), (ProofLang::Hr, hr::installed_path()), (ProofLang::Tr, tr::installed_path()), + (ProofLang::Ru, ru::installed_path()), + (ProofLang::Cs, cs::installed_path()), (ProofLang::Id, id::installed_path()), ] } @@ -921,6 +923,8 @@ mod tests { ("pt_BR", pt::test_dict::AFF, pt::test_dict::DIC), ("it_IT", it::test_dict::AFF, it::test_dict::DIC), ("hr_HR", hr::test_dict::AFF, hr::test_dict::DIC), + ("ru_RU", ru::test_dict::AFF, ru::test_dict::DIC), + ("cs_CZ", cs::test_dict::AFF, cs::test_dict::DIC), ("id_ID", id::test_dict::AFF, id::test_dict::DIC), ] { std::fs::write(dir.join(format!("{name}.aff")), aff).unwrap(); @@ -942,7 +946,16 @@ mod tests { (ProofLang::Hr, Some(dir.join("hr_HR.dic"))), ] ); + // #3226: Russian and Czech were missing from installed_dictionaries() entirely (no + // installed_path() in either module), so neither ever showed up in File › Options › + // Proofing, installed or not. + assert_eq!( + found[5..7], + [(ProofLang::Ru, Some(dir.join("ru_RU.dic"))), (ProofLang::Cs, Some(dir.join("cs_CZ.dic")))], + "Russian and Czech are reported too, between Turkish and Indonesian" + ); assert!(is_correct_in("chrząszcz", ProofLang::Pl) && !is_correct_in("chrzonszcz", ProofLang::Pl)); + assert!(is_correct_in("дом", ProofLang::Ru) && !is_correct_in("дум", ProofLang::Ru)); } /// #1741: a list item may be a fragment, so its first word needs no capital in any language diff --git a/crates/proof/src/ru/mod.rs b/crates/proof/src/ru/mod.rs index 4515c695..ffd09f7e 100644 --- a/crates/proof/src/ru/mod.rs +++ b/crates/proof/src/ru/mod.rs @@ -78,6 +78,13 @@ pub fn reload_dictionary() { *DICT.write().unwrap_or_else(|e| e.into_inner()) = None; } +/// The `.dic` file of the installed Russian dictionary, searching the dictionaries folder and +/// the system locations now (File › Options › Proofing shows it, #3226); `None` when there is +/// none. A dictionary given with [`install_dictionary`] has no file and isn't reported. +pub fn installed_path() -> Option { + crate::hunspell::find(NAMES).map(|(_, dic)| dic) +} + /// Is a Russian dictionary available (spelling is checked)? pub fn has_dictionary() -> bool { !dictionary().is_empty()