From 4181755db6314e5393ad819005c4f2659e7262ae Mon Sep 17 00:00:00 2001 From: bflatastic Date: Sat, 10 Oct 2026 06:02:48 +0700 Subject: [PATCH] Hyphenation exceptions: unit tests read only their thread's list hyphenation_exceptions_override_the_pattern failed when the round-trip test set the process-wide list at the same moment: words missing from the thread's override fell through to the shared store. Co-Authored-By: Claude Opus 5.5 --- crates/text/src/hyphen.rs | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/crates/text/src/hyphen.rs b/crates/text/src/hyphen.rs index 93acd4ba..120d7e9c 100644 --- a/crates/text/src/hyphen.rs +++ b/crates/text/src/hyphen.rs @@ -90,17 +90,18 @@ fn normalize_word(word: &str) -> String { word.chars().flat_map(|c| c.to_lowercase()).collect() } -/// Look the word up under the preferences lock (or the thread-local test override). Only the matched -/// [`Exception`] is cloned, never the whole list. +/// Look the word up under the preferences lock. Only the matched [`Exception`] is cloned, never +/// the whole list. +#[cfg(not(test))] fn exception_for(word: &str) -> Option { - let key = normalize_word(word); - #[cfg(test)] - { - if let Some(ex) = TEST_OVERRIDE.with(|c| c.borrow().as_ref().and_then(|e| e.map.get(&key).cloned())) { - return Some(ex); - } - } - store().map.get(&key).cloned() + store().map.get(&normalize_word(word)).cloned() +} + +/// Unit tests read only their own thread's list: tests running in parallel set the process-wide +/// one. +#[cfg(test)] +fn exception_for(word: &str) -> Option { + TEST_OVERRIDE.with(|c| c.borrow().as_ref().and_then(|e| e.map.get(&normalize_word(word)).cloned())) } fn is_vowel(c: char) -> bool {