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:
BFlat
2026-11-11 16:05:17 +07:00
committed by GitHub
2 changed files with 8 additions and 4 deletions
+2 -1
View File
@@ -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
+6 -3
View File
@@ -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);
}