Keep file format options attached to their original drawing

This commit is contained in:
dotCooCoo committed 2026-11-26 17:36:16 -08:00
1 parent c3576a7143
commit cc7654aa53
2 files changed
+22 -3

No files matched your search

+4 -3
View File
@@ -92,8 +92,8 @@ impl ExportDialogs {
impl Open {
fn check_source(&self, app: &VectorcraftApp) -> Result<(), String> {
if !matches!(self.kind, Export::Hpgl { .. }) && self.document != app.session.active().map(|doc| doc.uid) {
return Err(tl!("Return to the original drawing to export it").into());
if !matches!(self.kind, Export::As { .. } | Export::Hpgl { .. }) && self.document != app.session.active().map(|doc| doc.uid) {
return Err(tl!("Return to the original drawing to continue").into());
}
Ok(())
}
@@ -108,7 +108,8 @@ pub(super) fn options<L: From<&'static str>>(ids: &[&'static str], labels: &[&'s
/// replaces the one open, and its record.
pub(crate) fn open(app: &mut VectorcraftApp, kind: Export, selection: bool, dialog: HostedParamDialog) -> Option<DialogId> {
let document = match &kind {
Export::As { document } | Export::Hpgl { doc: document } => Some(*document),
Export::As { document } => *document,
Export::Hpgl { doc } => Some(*doc),
Export::EpsCustom { parent } => app.export_dialogs.find(*parent)?.document,
_ => app.session.active().map(|doc| doc.uid),
};
@@ -513,6 +513,24 @@ fn eps_save_transparency_follows_the_color_preview() {
assert_eq!(dialog(&mut app).bool("embedFonts"), Some(true));
}
#[test]
fn a_native_save_options_draft_cannot_redirect_its_path_to_another_drawing() {
let (mut app, written, _) = desktop("original.vectorcraft");
assert_eq!(save_as(&mut app, "file.saveAs").as_deref(), Some(KIND));
let draft_path = dialog(&mut app).text("path").unwrap().to_owned();
app.run("file.new", json!({"width": 200, "height": 120})).unwrap();
app.run("shape.rectangle", json!({"x": 10, "y": 10, "width": 30, "height": 20})).unwrap();
assert!(!ok(&mut app));
assert_eq!(dialog(&mut app).text("path"), Some(draft_path.as_str()));
assert!(written.borrow().is_empty());
assert!(app.session.active().unwrap().path.is_none());
app.run("document.activate", json!({"index": 0})).unwrap();
assert!(ok(&mut app), "{}", app.ui.status);
assert_eq!(written.borrow()[0].0, draft_path);
assert!(app.session.documents()[1].path.is_none());
}
/// #4931: a native file's Version is a menu of the versions VectorCraft writes, the current one
/// first and chosen, each named by the releases that read it. An older version without
/// compression saves plain, whatever Use Compression held.