From a976caf85763c080ebbb003441732e971a2c034e Mon Sep 17 00:00:00 2001 From: Mex <44814932+MMexicann@users.noreply.github.com> Date: Sat, 21 Nov 2026 19:16:29 +0100 Subject: [PATCH] Cover widely spaced comment pins in a real viewport --- crates/engine/src/comments_polish_tests.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/crates/engine/src/comments_polish_tests.rs b/crates/engine/src/comments_polish_tests.rs index c6690ce4a..9fb0bf736 100644 --- a/crates/engine/src/comments_polish_tests.rs +++ b/crates/engine/src/comments_polish_tests.rs @@ -273,6 +273,21 @@ fn links_open_and_zoom_to_a_thread() { assert!(s.execute("comment.zoom", &json!({"ids": [12345]})).is_err()); } +#[test] +fn zoom_to_spread_out_comments_keeps_both_pins_in_view() { + let mut s = Session::new(); + let a = add(&mut s, 0.0, 0.0, "Left", "Sam"); + let b = add(&mut s, 800.0, 0.0, "Right", "Sam"); + s.execute("view.set", &json!({"zoom": 1, "cx": 400, "cy": 0, "vw": 1200, "vh": 800})).unwrap(); + + s.execute("comment.zoom", &json!({"ids": [a, b]})).unwrap(); + + let v = &s.ds().unwrap().view; + let (left, _) = v.origin(); + let right = left + v.vw / v.zoom; + assert!(left <= 0.0 && right >= 800.0, "both pins should fit in the visible range {left}..{right}"); +} + #[test] fn next_steps_through_the_list_across_pages() { let mut s = Session::new();