LightCraft: An open-source non-destructive photo editor written by scratch in pure Rust
test: the format-message scan skips only inline test modules
aiongg259208948b35
diff --git a/crates/ui-egui/src/i18n/tests.rs b/crates/ui-egui/src/i18n/tests.rsindex 8e361ee12..2a44072f0 100644--- a/crates/ui-egui/src/i18n/tests.rs+++ b/crates/ui-egui/src/i18n/tests.rs@@ -1041,13 +1041,7 @@ fn format_messages() -> std::collections::BTreeSet<String> {dirs.push(path);} else if path.extension().is_some_and(|ext| ext == "rs") {let source = std::fs::read_to_string(&path).unwrap();- let app = source- .split(- "#[cfg(test)]-mod ",- )- .next()- .unwrap_or_default();+ let app = test_module_start(&source).map_or(source.as_str(), |at| &source[..at]);all.extend(tr_format_messages(app));}}@@ -1055,6 +1049,16 @@ mod ",all}+/// Where the first inline `#[cfg(test)] mod x { … }` starts. A `#[cfg(test)] mod x;` line only+/// declares a file, and app code can follow it.+fn test_module_start(source: &str) -> Option<usize> {+ let head = "#[cfg(test)]\nmod ";+ source+ .match_indices(head)+ .map(|(at, _)| at)+ .find(|at| source[at + head.len()..].trim_start_matches(|c: char| c.is_alphanumeric() || c == '_').starts_with(" {"))+}+/// The first argument of each `tr_format!` call in `source`, when it is a string literal.fn tr_format_messages(source: &str) -> Vec<String> {// built from parts, so this file's own source holds no call to find