PhotoCraft: An open-source, photo editor written by scratch in pure Rust
Recent files: a saved document is listed, as an opened one is (#4400) (#4411)
F4LCON6c2934ba797c
diff --git a/crates/ui-egui/src/file_open/tests.rs b/crates/ui-egui/src/file_open/tests.rsindex d49ab5820..9a833b7ba 100644--- a/crates/ui-egui/src/file_open/tests.rs+++ b/crates/ui-egui/src/file_open/tests.rs@@ -776,3 +776,20 @@ fn a_set_of_background_opens_keeps_its_order_however_they_finish() {jobs_ui::finish_open_tab(&mut app, &late, &json!({"document": index})).unwrap();assert_eq!(doc_names(&app), ["dropped.psd", "existing.psd", "f0.psd", "f1.psd", "f2.psd", "f3.psd", "late.psd"]);}++/// #4400: a new document saved under a name is listed in Open Recent (and on the Home screen),+/// as opening it is; a Save a Copy isn't, since the document doesn't live there.+#[test]+fn saving_a_new_document_lists_it_in_recent_files() {+ let (mut app, _written) = app_with(vec![Some(FileDialogAnswer::SaveTo("/pics/new.psd".into())), Some(FileDialogAnswer::SaveTo("/pics/copy.png".into()))]);+ let ctx = egui::Context::default();+ app.run("file.new", json!({"width": 4, "height": 4})).unwrap();+ assert!(app.ui.recent_files.is_empty());+ menus::invoke(&mut app, &ctx, "file.saveAs", json!({})).unwrap();+ answer(&mut app);+ assert_eq!(app.ui.recent_files, ["/pics/new.psd"]);+ assert_eq!(app.session.prefs().file_handling.recent_files, ["/pics/new.psd"], "kept for the next launch");+ menus::invoke(&mut app, &ctx, "file.saveACopy", json!({})).unwrap();+ answer(&mut app);+ assert_eq!(app.ui.recent_files, ["/pics/new.psd"], "a copy isn't the document's file");+}diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rsindex d03885937..b6d844b80 100644--- a/crates/ui-egui/src/lib.rs+++ b/crates/ui-egui/src/lib.rs@@ -1450,6 +1450,11 @@ impl PhotocraftApp {}Ok(())});+ // The file the document now lives in goes to the top of Open Recent and the Home+ // screen, as opening it does (#4400). Automation saves don't touch the user's list.+ if hooks {+ self.push_recent(path);+ }}self.ui.status_error = false;let what = crate::i18n::fmt(tl!("Saved {name}"), &[("name", file_open::display_name(path).as_str())]);