Fix #4523: a new document's VectorCraft Options start as the last native save used them

Preview, Embed ICC Profiles, Create PDF-Compatible File and the other VectorCraft Options went back to their defaults for every document not saved yet. A native Save or Save As now records the options it used in the preferences (not the artboards it picked, nor Use Compression, which its preference decides), and file.formatOptions offers them for a document not yet saved as a native file. A document saved before keeps its own.
This commit is contained in:
bflatastic
2026-10-29 19:57:57 +07:00
parent 098c147b60
commit a353ad3e7a
4 changed files with 35 additions and 3 deletions
+16
View File
@@ -99,6 +99,22 @@ fn save_as_takes_on_path_format_and_options() {
let _ = std::fs::remove_dir_all(d);
}
/// #4523: a new document's VectorCraft Options start as the last native save used them (not its
/// artboard range, nor Use Compression, which its preference decides).
#[test]
fn a_new_document_offers_the_native_options_used_last() {
let d = dir("lastnative");
let mut s = session();
let opts = json!({"preview": true, "embedProfiles": false, "pdfCompatible": true, "separateArtboards": true, "range": "1"});
s.execute("file.saveAs", &json!({"path": path(&d, "a.vectorcraft"), "options": opts})).unwrap();
s.execute("file.new", &json!({"width": 100, "height": 100})).unwrap();
let o = s.execute("file.formatOptions", &json!({"format": "vectorcraft"})).unwrap();
let value = |k: &str| o["options"][k]["value"].clone();
assert_eq!((value("preview"), value("embedProfiles"), value("pdfCompatible")), (json!(true), json!(false), json!(true)));
assert_eq!((value("separateArtboards"), value("range")), (o["options"]["separateArtboards"]["default"].clone(), o["options"]["range"]["default"].clone()));
let _ = std::fs::remove_dir_all(d);
}
#[test]
fn another_format_without_a_path_hands_the_bytes_back() {
let d = dir("otherfmt");