mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-18 13:33:51 +00:00
Width Point: stroke.widthPoint.set refuses outgoing widths without outIndex
A call with outLeft or outRight but no outIndex set the incoming point alone and reported success, so the outgoing widths were dropped. It is now refused as a missing outIndex, and the document and history stay as they are.
This commit is contained in:
@@ -367,8 +367,10 @@ fn width_point_set(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
Some(_) => return Err(bad(C, "`single` must be `incoming` or `outgoing`")),
|
||||
};
|
||||
// The outgoing half of a discontinuous point: its index and side widths (points).
|
||||
// `single`, `outLeft` or `outRight` without `outIndex` is refused as a missing `outIndex`.
|
||||
let out_widths = ["outLeft", "outRight"].iter().any(|k| p.get(*k).is_some_and(|v| !v.is_null()));
|
||||
let out = match p.get("outIndex") {
|
||||
None | Some(Value::Null) if single.is_none() => None,
|
||||
None | Some(Value::Null) if single.is_none() && !out_widths => None,
|
||||
_ => {
|
||||
let j = usize::try_from(u64_req(p, "outIndex", C)?).map_err(|_| bad(C, "no such width point"))?;
|
||||
let (l, r) = (f64_req(p, "outLeft", C)?, f64_req(p, "outRight", C)?);
|
||||
|
||||
@@ -275,6 +275,8 @@ fn paired_set_refuses_what_is_not_one_discontinuous_point() {
|
||||
pair(json!({"outLeft": 1.0e6})),
|
||||
pair(json!({"single": "both"})),
|
||||
pair(json!({"single": true})),
|
||||
pair(json!({"outIndex": null})),
|
||||
pair(json!({"outIndex": null, "outLeft": null})),
|
||||
json!({"id": id.0, "index": 2, "t": 0.5, "left": 5, "right": 5, "single": "incoming"}),
|
||||
] {
|
||||
assert!(s.execute("stroke.widthPoint.set", &p).is_err(), "accepted {p}");
|
||||
|
||||
Reference in New Issue
Block a user