From af404cfb9f86d83097f08ca8edb9a980e4f518fb Mon Sep 17 00:00:00 2001 From: aiongg Date: Sun, 1 Nov 2026 13:14:09 +0000 Subject: [PATCH] Trim the preset file name like the engine, and list the clash prompt's plural forms for translation (#10640) --- .../src/dialogs/preset_group_prompt.rs | 20 +++++++++++++++---- crates/ui-egui/src/preset_files_ui.rs | 13 +++++++++++- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/crates/ui-egui/src/dialogs/preset_group_prompt.rs b/crates/ui-egui/src/dialogs/preset_group_prompt.rs index 55f07d6d4d5..d33c789b8e3 100644 --- a/crates/ui-egui/src/dialogs/preset_group_prompt.rs +++ b/crates/ui-egui/src/dialogs/preset_group_prompt.rs @@ -49,12 +49,24 @@ pub(crate) fn intercept(app: &mut PhotocraftApp, held: Held) -> Result Option return Some(crate::kys_import::open_bytes(app, name, bytes).map(|_| ())), _ => return None, }; - let stem = std::path::Path::new(name).file_stem().map(|s| s.to_string_lossy().to_string()).unwrap_or_else(|| tl!("Imported").into()); + // Trimmed like the engine trims `group`, so the clash check sees the name the import uses. + let stem = std::path::Path::new(name) + .file_stem() + .map(|s| s.to_string_lossy().trim().to_string()) + .filter(|s| !s.is_empty()) + .unwrap_or_else(|| tl!("Imported").into()); let mut p = source(name, bytes); p["group"] = json!(stem); if what == "brushes" { @@ -203,6 +208,12 @@ mod tests { assert_eq!((in_group(&app, "Kit"), in_group(&app, "Kit (2)")), (2, 0)); assert!(app.held_preset_import.is_none()); + // A file name with a trailing space (`Kit .abr`) names the same group. + open(&mut app, "Kit .abr", &abr).unwrap().unwrap(); + let id = prompt(&app).expect("the prompt is open for the trimmed name"); + crate::dialogs::cancel(&mut app, id).unwrap(); + assert_eq!(in_group(&app, "Kit (2)"), 0); + // The default answer imports beside it. open(&mut app, "Kit.abr", &abr).unwrap().unwrap(); let id = prompt(&app).expect("the prompt is open");