mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-09 11:54:03 +00:00
fix(engine): Delete Design handles each listed name once
This commit is contained in:
committed by
bflatastic
parent
f854b7a2cf
commit
dabb9ae380
@@ -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}`")));
|
||||
}
|
||||
|
||||
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user