fix(engine): Delete Design handles each listed name once

This commit is contained in:
Dylan M. Taylor
2026-11-03 22:17:45 +07:00
committed by bflatastic
parent f854b7a2cf
commit dabb9ae380
2 changed files with 6 additions and 0 deletions
+2
View File
@@ -145,6 +145,8 @@ pub(super) fn design(s: &mut Session, p: &Value) -> Result<Value> {
return Ok(json!({ "id": id.0 }));
}
if let Some(names) = names_param(p, "delete", C)? {
// Each name once: a repeated one would regenerate the graphs using it again.
let names: std::collections::BTreeSet<String> = names.into_iter().collect();
if let Some(n) = names.iter().find(|n| !taken(s, n)) {
return Err(bad(C, format!("no design named `{n}`")));
}
+4
View File
@@ -1304,6 +1304,10 @@ fn graph_designs_are_saved_pasted_and_deleted() {
s.execute("edit.undo", &json!({})).unwrap();
assert!(series_parts(&s, id, 0).iter().skip(1).all(|n| matches!(n.kind, NodeKind::Group { .. })));
assert!(s.execute("graph.design", &json!({"delete": "Nope"})).is_err());
// A name listed many times deletes once (its graphs regenerate once).
s.execute("graph.design", &json!({"delete": vec!["Pill"; 1000]})).unwrap();
assert!(s.doc().unwrap().doc.graph_designs.is_empty());
assert!(series_parts(&s, id, 0).iter().all(|n| matches!(n.kind, NodeKind::Path { .. })));
}
#[test]