From 2d5fb1279a1b6dea7239a62b9d9d8a9dd99133d2 Mon Sep 17 00:00:00 2001 From: Marco Arnulfo <103679419+marcoarnulfo@users.noreply.github.com> Date: Sun, 18 Oct 2026 17:33:30 +0200 Subject: [PATCH] Proofing: a hyphenated word added to the dictionary is no longer flagged (fixes storytold/wordcraft#2082) (storytold/wordcraft#2085) Co-authored-by: Brandon Thomas --- crates/proof/src/lib.rs | 7 +++++-- crates/proof/src/pt/mod.rs | 10 ++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/crates/proof/src/lib.rs b/crates/proof/src/lib.rs index 627853a0..28dfb582 100644 --- a/crates/proof/src/lib.rs +++ b/crates/proof/src/lib.rs @@ -407,14 +407,17 @@ pub fn is_correct(word: &str) -> bool { } /// The words every language's check accepts under `opts`: single letters, words without -/// letters, words with digits (Ignore words that contain numbers) and words in capitals -/// (Ignore words in UPPERCASE). +/// letters, words with digits (Ignore words that contain numbers), words in capitals +/// (Ignore words in UPPERCASE) and words in the user dictionary. fn accepted_by_options(word: &str, opts: &Options) -> bool { let w = word.trim_matches(|c: char| !c.is_alphanumeric() && c != '\'').trim_matches('\''); w.chars().count() <= 1 || !w.chars().any(char::is_alphabetic) || (opts.ignore_numbers && w.chars().any(|c| c.is_ascii_digit())) || (opts.ignore_uppercase && w.chars().all(|c| !c.is_lowercase())) + // The whole word: the languages split a hyphenated word into its parts, and an added + // `Unigranrio-RJ` is none of them (#2082). + || in_user_dictionary(&w.to_lowercase()) } /// [`is_correct`] with the File › Options › Proofing choices. diff --git a/crates/proof/src/pt/mod.rs b/crates/proof/src/pt/mod.rs index d175f63c..24c3d3b8 100644 --- a/crates/proof/src/pt/mod.rs +++ b/crates/proof/src/pt/mod.rs @@ -206,4 +206,14 @@ mod tests { crate::add_word("Zxqportuguespalavra"); assert!(is_correct("zxqportuguespalavra")); } + + #[test] + fn user_dictionary_accepts_a_hyphenated_word_whole() { + test_dict::install(); + let text = "Ele disse que está na Unigranrio-RJ."; + assert_eq!(crate::check_spelling_in(text, crate::ProofLang::Pt).len(), 1, "Unigranrio isn't in the dictionary"); + // Added as the context menu adds it, hyphen and all (#2082). + crate::add_word("Unigranrio-RJ"); + assert!(crate::check_spelling_in(text, crate::ProofLang::Pt).is_empty()); + } }