From cecaf16baea2ecb17285b7825c7544c2ae8e00cf Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Tue, 24 Nov 2026 20:39:34 -0800 Subject: [PATCH] Circle: switching Third Point by Dragging keeps a center placed with From Center --- crates/tools/src/circle.rs | 3 ++- crates/tools/src/circle/tests.rs | 18 ++++++++++++++++++ docs/mcp.md | 2 +- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/crates/tools/src/circle.rs b/crates/tools/src/circle.rs index 738141a993..37c0e33bcd 100644 --- a/crates/tools/src/circle.rs +++ b/crates/tools/src/circle.rs @@ -640,7 +640,8 @@ impl Tool for CircleTool { if let Some(switch) = self.options.switch(key) { *switch = on; } - if self.options.drag_third != was { + // A circle drawn from its center has no third point, so its center stays placed. + if self.options.drag_third != was && !self.centered { self.clear(); } } diff --git a/crates/tools/src/circle/tests.rs b/crates/tools/src/circle/tests.rs index 20cf56977b..3264a771e8 100644 --- a/crates/tools/src/circle/tests.rs +++ b/crates/tools/src/circle/tests.rs @@ -857,6 +857,24 @@ fn from_center_holds_for_the_circle_being_drawn() { assert_eq!(t.options()["fromCenter"], json!(false), "a value that is not true or false is ignored"); } +/// Switching `dragThird` while a center is placed keeps the center: the circle from it is still +/// drawn. Without From Center, the switch drops the point placed. +#[test] +fn switching_third_point_by_dragging_keeps_a_placed_center() { + let (d, _) = doc_with_rect(); + let (s, p) = (Selection::default(), paint()); + let cx = ToolContext { smart_guides: false, ..cx(&d, &s, &p) }; + let mut t = from_center(); + click(&mut t, &cx, (100.0, 100.0)); + t.set_option("dragThird", &json!(false)); + assert!(t.ends_on_escape(&cx), "the center is still placed"); + assert_eq!(click(&mut t, &cx, (100.0, 150.0)), centered((100.0, 100.0), (100.0, 150.0))); + let mut t = CircleTool::default(); + click(&mut t, &cx, (100.0, 100.0)); + t.set_option("dragThird", &json!(false)); + assert!(!t.ends_on_escape(&cx), "the first point is dropped"); +} + /// `tool.setOption` takes `fromCenter` as true or false, and no other key. #[test] fn the_options_are_checked() { diff --git a/docs/mcp.md b/docs/mcp.md index da42323ebe..78e18df020 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -7396,7 +7396,7 @@ default except `fromCenter`, which is off, and `color` is `"blue"`: the opposite corner, with the diagonal as its radius. Shift keeps the second point at 45° steps from the center, and Alt rounds the diameter (twice the distance from the center) to the nearest ruler tick. The tool shows one radius, to the pointer. A second click on the center places nothing. The setting in force when the first point is placed applies - to that circle, and `dragThird` does not apply to it. + to that circle, and `dragThird` does not apply to it: switching `dragThird` keeps a placed center. `tool.setOption` returns an error and changes none of the options when a value is not one the option takes (`` `radii` must be true or false ``, `` `color` must be one of red, blue, magenta, green, black, gray ``) or the key is