From 391e0881b4e75294694916c1a8aa01f1e400bb08 Mon Sep 17 00:00:00 2001 From: texjer Date: Wed, 4 Nov 2026 19:56:42 -0500 Subject: [PATCH] Place: the grid tool sends the gutter it previews The preview's 6 pt duplicated place.grid's default, so changing one would leave the preview out of step with what lands. The tool now sends its gutter with the command. --- crates/tools/src/nav.rs | 5 +++-- crates/tools/src/tests.rs | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/crates/tools/src/nav.rs b/crates/tools/src/nav.rs index c86fc4fec..456c73ba9 100644 --- a/crates/tools/src/nav.rs +++ b/crates/tools/src/nav.rs @@ -155,7 +155,7 @@ impl Tool for PlaceGun { if !grid_cells(r, self.columns, self.rows).is_empty() { return vec![Action::Exec( "place.grid".into(), - json!({"spread": crate::spread_json(sr), "rect": [r.x0, r.y0, r.x1, r.y1], "columns": self.columns, "rows": self.rows}), + json!({"spread": crate::spread_json(sr), "rect": [r.x0, r.y0, r.x1, r.y1], "columns": self.columns, "rows": self.rows, "gutter": PLACE_GRID_GUTTER}), )]; } // The frame the drag drew: at the graphic's proportions from where it started. @@ -239,7 +239,8 @@ Y: {pct}" } } -/// The gutter between place-grid cells, in points: `place.grid`'s default. +/// The gutter between place-grid cells, in points. The tool sends it with `place.grid`, so the +/// preview and what lands can't disagree if the command's default changes. const PLACE_GRID_GUTTER: f64 = 6.0; /// The cells of a `columns` × `rows` place grid drawn over `rect`, [`PLACE_GRID_GUTTER`] apart, as diff --git a/crates/tools/src/tests.rs b/crates/tools/src/tests.rs index 9fd67fdd8..4949e20e4 100644 --- a/crates/tools/src/tests.rs +++ b/crates/tools/src/tests.rs @@ -2459,7 +2459,7 @@ fn place_gun_grid_preview_matches_the_release_on_a_rotated_spread() { assert_eq!(t.key(&cx, ToolKey::Right, Mods::default()), vec![Action::Handled]); let shown = t.overlays(&cx); let out = t.pointer(&cx, &PointerEvent::new(PointerKind::Up, end.x, end.y)); - assert!(matches!(out.as_slice(), [Action::Exec(cmd, p)] if cmd == "place.grid" && p["columns"] == 2), "{out:?}"); + assert!(matches!(out.as_slice(), [Action::Exec(cmd, p)] if cmd == "place.grid" && p["columns"] == 2 && p["gutter"] == 6.0), "{out:?}"); // Two columns on the spread, 6 pt apart, each shown where its corners land on the canvas. let r = Rect::from_points(a, b); let w = (r.width() - 6.0) / 2.0;