diff --git a/crates/tools/src/guides/targets.rs b/crates/tools/src/guides/targets.rs index 41b9f517ee..f2a451f110 100644 --- a/crates/tools/src/guides/targets.rs +++ b/crates/tools/src/guides/targets.rs @@ -568,8 +568,10 @@ impl Targets { } /// View → Snap to Point: only these targets' anchors pull, and the ruler guides (shown and - /// unlocked, as the selection tools pick them) pull the pointer into line where they run. - pub(super) fn for_snap_to_point(self, cx: &ToolContext) -> Self { + /// unlocked, as the selection tools pick them) pull the pointer into line where they run. It + /// snaps without Smart Guides, so it draws none of their labels and lines. + pub(super) fn for_snap_to_point(mut self, cx: &ToolContext) -> Self { + self.style = GuideStyle { lines: false, labels: false, ..GuideStyle::of(cx) }; self.anchors_only().with_rulers(cx) } diff --git a/crates/tools/src/guides/tests.rs b/crates/tools/src/guides/tests.rs index a4f3bc49fd..1b6ddbaa12 100644 --- a/crates/tools/src/guides/tests.rs +++ b/crates/tools/src/guides/tests.rs @@ -952,3 +952,26 @@ fn a_drawn_point_lands_on_a_corner_of_a_glyphs_bounds() { assert!((q - tr).cross(dir).abs() < 1e-6, "angle {angle}: {q:?} is off the right edge"); } } + +/// With Smart Guides off, View → Snap to Point still pulls a drawn point onto an anchor, but +/// draws no Smart Guides: no "anchor" label, no lines. +#[test] +fn snap_to_point_without_smart_guides_shows_no_guides() { + let (d, _) = doc_with_rect(); + let (s, p) = (Selection::default(), paint()); + // Within Snap to Point's 2 px of the anchor at (200, 200). + let at = Point::new(201.0, 199.0); + let off = ToolContext { smart_guides: false, snap_to_point: true, ..cx(&d, &s, &p) }; + let mut snap = DrawSnap::default(); + assert_eq!(snap.hover(&off, at, &[], None), Point::new(200.0, 200.0)); + assert!(snap.guides().is_empty(), "{:?}", snap.guides()); + assert_eq!(snap.press(&off, at, &[], None), Point::new(200.0, 200.0)); + assert!(snap.guides().is_empty(), "{:?}", snap.guides()); + // A dragged selection's grabbed point too. + let (q, ov) = Targets::snap_to_point(&off, &[]).unwrap().snap_point(at, 4.0); + assert_eq!((q, ov.len()), (Point::new(200.0, 200.0), 0), "{ov:?}"); + // Smart Guides on: the same point says "anchor". + let mut snap = DrawSnap::default(); + assert_eq!(snap.hover(&cx(&d, &s, &p), at, &[], None), Point::new(200.0, 200.0)); + assert_eq!(labels(snap.guides()), ["anchor"]); +}