DesignCraft: An open-source page and layout design editor written by scratch in pure Rust
Text wrap: an all-null offset array keeps a custom boundary
moppeeer7a50e480819f
diff --git a/crates/engine/src/cmd/object.rs b/crates/engine/src/cmd/object.rsindex b47eb3a2d..44e8dce96 100644--- a/crates/engine/src/cmd/object.rs+++ b/crates/engine/src/cmd/object.rs@@ -2109,9 +2109,10 @@ fn text_wrap(s: &mut Session, p: &Value) -> Result<Value> {};// Per side [top, left, bottom, right]; a null side keeps each object's own offset there, so// an edit of one side keeps the others of every object.+ // An array with no number in it changes no offset (and so keeps a custom boundary).let off: Option<[Option<f64>; 4]> = match p.get("offset") {Some(Value::Number(n)) => Some([n.as_f64(); 4]),- Some(v) => serde_json::from_value(v.clone()).ok(),+ Some(v) => serde_json::from_value::<[Option<f64>; 4]>(v.clone()).ok().filter(|o| o.iter().any(Option::is_some)),None => None,};let invert = p.get("invert").and_then(Value::as_bool);diff --git a/crates/engine/src/tests.rs b/crates/engine/src/tests.rsindex b1792485d..243e73759 100644--- a/crates/engine/src/tests.rs+++ b/crates/engine/src/tests.rs@@ -868,6 +868,9 @@ fn custom_wrap_path_follows_resize_and_yields_to_offsets() {s.execute("transform.resize", &json!({"from": [b.x0, b.y0, b.x1, b.y1], "to": to})).unwrap();let w = wrap_path(&s).unwrap().bounds().unwrap();assert!((w.width() - 80.0).abs() < 1e-6 && (w.height() - 100.0).abs() < 1e-6, "{w:?}");+ // Offsets that are all null change nothing, so the boundary stays.+ s.execute("object.textWrap", &json!({"mode": null, "offset": [null, null, null, null]})).unwrap();+ assert!(wrap_path(&s).is_some(), "an all-null offset keeps the custom boundary");// An offset rebuilds the wrap from the frame.s.execute("object.textWrap", &json!({"offset": 6})).unwrap();assert_eq!(wrap_path(&s), None);