Skip to content

LightCraft: An open-source non-destructive photo editor written by scratch in pure Rust

LRC-LIB-KEYWORDS: names left out of a keyword list show on one line

Nathaniel Ledford4e9cffe375fd
diff --git a/crates/ui-egui/src/menus.rs b/crates/ui-egui/src/menus.rs
index 7ab031e6f..1e8aedfb8 100644
--- a/crates/ui-egui/src/menus.rs
+++ b/crates/ui-egui/src/menus.rs
@@ -1416,7 +1416,8 @@ pub fn run_ui_command(app: &mut LightcraftApp, id: &str, p: &Value) -> Option<Re
if !left.is_empty() {
msg.push_str(&crate::i18n::tr_format!(
" — left out, as a keyword list can't hold them: {names}",
- names = left.iter().take(5).copied().collect::<Vec<_>>().join(" · ")
+ // escaped: a line break in a name would break the toast
+ names = left.iter().take(5).map(|n| n.escape_debug().to_string()).collect::<Vec<_>>().join(" · ")
));
}
app.toast(&ctx, msg);
diff --git a/crates/ui-egui/src/tests_keyword_files.rs b/crates/ui-egui/src/tests_keyword_files.rs
index 9228efd48..f7180c317 100644
--- a/crates/ui-egui/src/tests_keyword_files.rs
+++ b/crates/ui-egui/src/tests_keyword_files.rs
@@ -86,6 +86,10 @@ fn exporting_keywords_names_what_it_left_out() {
let r = run(&mut h, "file.exportKeywords", json!({"path": path.to_string_lossy()}));
assert_eq!(r["ok"], true, "{r}");
assert!(toast(&h).contains("Travel|[draft]"), "{}", toast(&h));
+ // a name with a line break in it shows on one line
+ run(&mut h, "photo.setMeta", json!({"ids": [id], "addKeywords": ["Line\nbreak"]}));
+ run(&mut h, "file.exportKeywords", json!({"path": path.to_string_lossy()}));
+ assert!(toast(&h).contains("Line\\nbreak") && !toast(&h).contains('\n'), "{}", toast(&h));
let _ = std::fs::remove_dir_all(&dir);
}