From 00f123133462ee18cbc46e9b250643b2d16437c1 Mon Sep 17 00:00:00 2001 From: Hamza Date: Mon, 19 Oct 2026 21:25:18 +0500 Subject: [PATCH] Tab stops: Shift snaps to the ruler's binary inch ticks `shift_drag_snaps_a_stop_to_the_nearest_tick` landed while this branch was out and asserts the tick an inch ruler used to carry: "the ticks are a tenth of an inch (7.2 pt) apart", snapping 100 pt to 100.8. That tenth is what this change removes -- an inch ruler divides the inch in half, not in ten. The nearest tick to 100 pt is now 99 pt: 1 3/8 in, an eighth of an inch from 1 1/4. The test says so, and also asserts the result is a binary fraction of an inch rather than a particular number, so it holds if the ladder is retuned. --- crates/ui-egui/src/panels/tabs.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/panels/tabs.rs b/crates/ui-egui/src/panels/tabs.rs index 879f15196..2a5af459e 100644 --- a/crates/ui-egui/src/panels/tabs.rs +++ b/crates/ui-egui/src/panels/tabs.rs @@ -592,10 +592,12 @@ mod tests { let from = position(&app); drag_on_ruler(&ctx, &mut app, from, 41.6, true); assert_eq!(position(&app), 40.0); - // In an inches document the ticks are a tenth of an inch (7.2 pt) apart. + // In an inches document the ticks divide the inch in half, not in ten (#2827), so the + // nearest one to 100 pt is 99 pt -- 1 3/8 in, an eighth of an inch from 1 1/4. app.session.execute("document.setUnits", &json!({"units": "in"})).unwrap(); drag_on_ruler(&ctx, &mut app, 40.0, 100.0, true); - assert!((position(&app) - 100.8).abs() < 1e-9, "{}", position(&app)); + assert!((position(&app) - 99.0).abs() < 1e-9, "{}", position(&app)); + assert_eq!((position(&app) / 72.0 * 8.0).round(), position(&app) / 72.0 * 8.0, "a binary fraction of an inch"); } /// One frame of the panel menu with `events` → the rows' texts and where they are painted.