From 8b289bf6bbf374fec6a2db0c4dd15b553bcb2bd8 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Thu, 19 Nov 2026 05:49:14 -0800 Subject: [PATCH] Direct Selection: Cmd/Ctrl mirrors an ordinary path's handle again The handle drag that keeps Space translation sent path.setHandle without `symmetric`, so Cmd/Ctrl no longer mirrored the opposite handle on an ordinary path. The drag now records the mirror with the handle it accepts and sends it on every preview, so the opposite handle stays mirrored while Space moves the anchor. Alt still takes priority. --- crates/engine/tests/direct_handle_mirror.rs | 23 +++++++++++++++++++++ crates/tools/src/direct.rs | 7 +++++++ 2 files changed, 30 insertions(+) diff --git a/crates/engine/tests/direct_handle_mirror.rs b/crates/engine/tests/direct_handle_mirror.rs index d7fdfab36f..513824df8c 100644 --- a/crates/engine/tests/direct_handle_mirror.rs +++ b/crates/engine/tests/direct_handle_mirror.rs @@ -122,6 +122,29 @@ fn direct_handle_baseline_cmd_added_mid_drag_mirrors_the_opposite() { pointer(&mut s, PointerKind::Up, q, Mods { cmd: true, ..Mods::default() }); } +#[test] +fn direct_handle_cmd_mirror_holds_through_a_space_translation() { + let mut s = session(); + let id = curve(&mut s, Point::new(50.0, 100.0)); + press_handle(&mut s, Point::new(180.0, 100.0)); + let q = Point::new(180.0, 160.0); + pointer(&mut s, PointerKind::Drag, q, cmd()); + handles(anchor(&s, id), Point::new(20.0, 40.0), q, AnchorKind::Smooth); + // Space moves the anchor and both handles; the opposite handle stays mirrored. + let moved = Point::new(200.0, 190.0); + pointer(&mut s, PointerKind::Drag, moved, Mods { space: true, ..cmd() }); + let a = anchor(&s, id); + near(a.p, Point::new(120.0, 130.0)); + handles(a, Point::new(40.0, 70.0), Point::new(200.0, 190.0), AnchorKind::Smooth); + // Releasing Space without moving keeps the translated, mirrored handles. + pointer(&mut s, PointerKind::Drag, moved, cmd()); + handles(anchor(&s, id), Point::new(40.0, 70.0), Point::new(200.0, 190.0), AnchorKind::Smooth); + let next = Point::new(220.0, 190.0); + pointer(&mut s, PointerKind::Drag, next, cmd()); + assert_mirrored(anchor(&s, id), next, AnchorKind::Smooth); + pointer(&mut s, PointerKind::Up, next, cmd()); +} + #[derive(Debug, PartialEq)] struct Snapshot { document: Value, diff --git a/crates/tools/src/direct.rs b/crates/tools/src/direct.rs index 0ea7b79b08..b8394d0472 100644 --- a/crates/tools/src/direct.rs +++ b/crates/tools/src/direct.rs @@ -78,6 +78,8 @@ struct HandleDrag { offset: Vec2, space: bool, independent: bool, + /// The opposite handle mirrors this one ([`DirectSelectionTool::mirrors`]). + symmetric: bool, translated: bool, } @@ -948,6 +950,7 @@ impl Tool for DirectSelectionTool { offset: Vec2::ZERO, space: false, independent: false, + symmetric: false, translated: false, }) } @@ -1607,6 +1610,7 @@ impl DirectSelectionTool { self.guides = guides; drag.handle = q; drag.independent = ev.mods.alt; + drag.symmetric = self.mirrors(ev); } } drag.last = p; @@ -1615,6 +1619,9 @@ impl DirectSelectionTool { "id": id.0, "subpath": si, "anchor": ai, "which": if out { "out" } else { "in" }, "x": drag.handle.x, "y": drag.handle.y, "independent": drag.independent, }); + if drag.symmetric { + params["symmetric"] = json!(true); + } if drag.translated { params["at"] = json!([drag.at.x, drag.at.y]); }