LightCraft: An open-source non-destructive photo editor written by scratch in pure Rust
LRC-LIB-KEYWORDS: Export Keywords… says why it failed
Nathaniel Ledfordc3b9a1355786
diff --git a/crates/ui-egui/src/menus.rs b/crates/ui-egui/src/menus.rsindex c15c2c22d..7ab031e6f 100644--- a/crates/ui-egui/src/menus.rs+++ b/crates/ui-egui/src/menus.rs@@ -1397,6 +1397,9 @@ pub fn run_ui_command(app: &mut LightcraftApp, id: &str, p: &Value) -> Option<Re}};let r = app.session.execute("keyword.export", &json!({"path": path})).map_err(|e| e.to_string());+ if let Err(e) = &r {+ app.toast(&ctx, e.clone());+ }if let Ok(v) = &r {let n = v["keywords"].as_u64().unwrap_or(0);let mut msg = crate::i18n::tr_format!("Exported {n} keyword{}", if n == 1 { "" } else { "s" }, n = n);diff --git a/crates/ui-egui/src/tests_keyword_files.rs b/crates/ui-egui/src/tests_keyword_files.rsindex 257af9cd3..9228efd48 100644--- a/crates/ui-egui/src/tests_keyword_files.rs+++ b/crates/ui-egui/src/tests_keyword_files.rs@@ -88,3 +88,13 @@ fn exporting_keywords_names_what_it_left_out() {assert!(toast(&h).contains("Travel|[draft]"), "{}", toast(&h));let _ = std::fs::remove_dir_all(&dir);}++/// A list that can't be written (a folder that isn't there) says why, as importing one does.+#[test]+fn exporting_keywords_says_why_it_failed() {+ let mut h = app();+ let path = std::env::temp_dir().join("lc-no-such-folder-for-keywords").join("keywords.txt");+ let r = run(&mut h, "file.exportKeywords", json!({"path": path.to_string_lossy()}));+ assert_eq!(r["ok"], false, "{r}");+ assert!(toast(&h).contains("keywords.txt"), "{}", toast(&h));+}