mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-11 18:54:55 +00:00
Merge pull request #6550 from dotCooCoo/fix/reshape-empty-focal-radius
Reshape: an empty focal list cannot be combined with radius
This commit is contained in:
@@ -1578,7 +1578,8 @@ fn reshape(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
Some(v) if v.is_array() => super::select::checked_refs(Some(v), "path.reshape")?.into_iter().collect(),
|
||||
Some(_) => return Err(bad("path.reshape", "`focal` must be an array of [subpath, anchor] pairs")),
|
||||
};
|
||||
if radius.is_some() && !focal.is_empty() {
|
||||
// An empty `focal` chooses the focal-point rule too.
|
||||
if radius.is_some() && !matches!(p.get("focal"), None | Some(Value::Null)) {
|
||||
return Err(bad("path.reshape", "`focal` and `radius` cannot be used together"));
|
||||
}
|
||||
// A step that names neither `focal` nor `radius` (as the Reshape tool recorded one before it
|
||||
|
||||
@@ -3622,9 +3622,12 @@ fn reshape_refuses_a_focal_point_that_is_not_an_anchor() {
|
||||
}
|
||||
assert_eq!(reshape_anchors(&s, id), before);
|
||||
let steps = s.doc().unwrap().history.undo.len();
|
||||
let e =
|
||||
s.execute("path.reshape", &json!({"id": id.0, "x": 420.0, "y": 0.0, "dx": 0.0, "dy": 10.0, "focal": [[0, 2]], "radius": 50.0})).unwrap_err();
|
||||
assert!(e.to_string().contains("`focal` and `radius` cannot be used together"), "{e}");
|
||||
// An empty `focal` chooses the focal-point rule too, so it cannot go with `radius` either.
|
||||
for focal in [json!([[0, 2]]), json!([])] {
|
||||
let e =
|
||||
s.execute("path.reshape", &json!({"id": id.0, "x": 420.0, "y": 0.0, "dx": 0.0, "dy": 10.0, "focal": focal, "radius": 50.0})).unwrap_err();
|
||||
assert!(e.to_string().contains("`focal` and `radius` cannot be used together"), "{focal}: {e}");
|
||||
}
|
||||
assert_eq!(reshape_anchors(&s, id), before);
|
||||
assert_eq!(s.doc().unwrap().history.undo.len(), steps);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user