diff --git a/crates/engine-core/src/cmd/symmetry_path_delete_tests.rs b/crates/engine-core/src/cmd/symmetry_path_delete_tests.rs index 7de2c28fc2..177a1ef60e 100644 --- a/crates/engine-core/src/cmd/symmetry_path_delete_tests.rs +++ b/crates/engine-core/src/cmd/symmetry_path_delete_tests.rs @@ -46,6 +46,21 @@ fn deleting_the_symmetry_path_turns_symmetry_off_and_undo_brings_it_back() { assert!(symmetry(&s).is_null(), "redo deletes the path again, so symmetry is off again"); } +/// The work path answers to "work", "" and "Work Path" in `path.delete`, while symmetry stores +/// it as "work"; every alias must still turn symmetry off. +#[test] +fn deleting_the_work_path_by_an_alias_turns_symmetry_off_too() { + for alias in ["Work Path", ""] { + let mut s = session(); + s.execute("path.set", json!({"name": "work", "path": {"subpaths": [{"knots": [[100, 50], [200, 100]]}]}})).unwrap(); + s.execute("paint.symmetryFromPath", json!({"name": "work"})).unwrap(); + s.execute("path.delete", json!({"name": alias})).unwrap(); + assert!(symmetry(&s).is_null(), "{alias:?} deletes the work path, so symmetry is off"); + assert!(s.undo()); + assert_eq!(symmetry(&s)["source"], "work", "{alias:?}: undo brings the symmetry back"); + } +} + #[test] fn deleting_the_work_path_turns_symmetry_off_too() { let mut s = session(); diff --git a/crates/engine-core/src/cmd/vector_cmds/paths.rs b/crates/engine-core/src/cmd/vector_cmds/paths.rs index c7f91c9899..d3e07b2a2d 100644 --- a/crates/engine-core/src/cmd/vector_cmds/paths.rs +++ b/crates/engine-core/src/cmd/vector_cmds/paths.rs @@ -141,8 +141,11 @@ pub(super) fn path_set(s: &mut Session, p: &Value) -> Result { pub(super) fn path_delete(s: &mut Session, p: &Value) -> Result { let name = p.get("name").and_then(Value::as_str).map(str::to_string); - // Deleting the path that painting symmetry mirrors across leaves symmetry off (#17384). - let symmetry = crate::symmetry_cmds::symmetry_before_path_delete(s, name.as_deref().unwrap_or("work")); + // Deleting the path that painting symmetry mirrors across leaves symmetry off (#17384). The + // work path answers to "work", "" and "Work Path", while symmetry stores it as "work". + let deleted = name.as_deref().unwrap_or("work"); + let source = if is_work(Some(deleted)) { "work" } else { deleted }; + let symmetry = crate::symmetry_cmds::symmetry_before_path_delete(s, source); s.edit("Delete Path", |doc, _| { if is_work(name.as_deref()) { return doc.work_path.take().map(|_| ()).ok_or_else(|| EngineError::Other("no work path".into()));