From 56f0679fed05aa521d2e3665870a5d3456b9a098 Mon Sep 17 00:00:00 2001 From: adifiedio Date: Tue, 3 Nov 2026 13:13:29 +0530 Subject: [PATCH] Frozen panes: test the scrolled freeze-handle drag and the frozen text's painted extent (#2544) Review follow-up: a column-handle drop on the last frozen column while scrolled, which fails if freeze_boundary measures with x(c + 1), and a check that frozen A1's text lies inside its clip, not only that the clip is A1. --- crates/ui-egui/tests/it/freeze_handles.rs | 17 +++++++++++++++++ crates/ui-egui/tests/it/text_overflow_scroll.rs | 14 ++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/crates/ui-egui/tests/it/freeze_handles.rs b/crates/ui-egui/tests/it/freeze_handles.rs index e3ccf8c65..141d0b9ef 100644 --- a/crates/ui-egui/tests/it/freeze_handles.rs +++ b/crates/ui-egui/tests/it/freeze_handles.rs @@ -82,3 +82,20 @@ fn last_frozen_column_ends_at_the_freeze_line_when_scrolled() { assert!(g.x(&sh, 2) < split.x && g.y(&sh, 2) < split.y, "C and row 3 are scrolled under the frozen panes"); assert!(g.same_col_pane(0, 1) && g.same_col_pane(2, 9) && !g.same_col_pane(1, 2)); } + +/// Dropping the column handle on the left part of the last frozen column while scrolled freezes +/// up to its left edge: the column's right edge is the freeze line, not the next column's +/// scrolled position (#2544). +#[test] +fn dragging_the_column_handle_when_scrolled_measures_the_last_frozen_column() { + let mut h = harness(); + h.state_mut().run("view.freezePanes", serde_json::json!({"cell": "C1"})).unwrap(); + h.state_mut().view_mut().unwrap().scroll = egui::vec2(300.0, 0.0); + h.run_steps(2); + let g = geo(&h); + let sh = h.state().session.active().unwrap().wb.active().unwrap().clone(); + let (cols, _) = freeze_handles(&g); + assert!(g.x(&sh, 2) < g.x(&sh, 1), "C is scrolled left of B"); + drag(&mut h, cols.center(), pos2(g.x(&sh, 1) + 10.0, g.cells.top() + 40.0)); + assert_eq!(freeze(&h), Some((0, 1))); +} diff --git a/crates/ui-egui/tests/it/text_overflow_scroll.rs b/crates/ui-egui/tests/it/text_overflow_scroll.rs index 076478e52..371c0aeee 100644 --- a/crates/ui-egui/tests/it/text_overflow_scroll.rs +++ b/crates/ui-egui/tests/it/text_overflow_scroll.rs @@ -53,6 +53,18 @@ fn text_clips(h: &Harness, text: &str) -> Vec { .collect() } +/// Painted extents of the text shapes whose text is `text`, cut to their clip rects. +fn text_visible_rects(h: &Harness, text: &str) -> Vec { + h.output() + .shapes + .iter() + .filter_map(|s| match &s.shape { + Shape::Text(t) if t.galley.job.text == text => Some(t.visual_bounding_rect().intersect(s.clip_rect)), + _ => None, + }) + .collect() +} + fn cell_rect(h: &Harness, cell: &str) -> Rect { let app = h.state(); let sheet = app.session.active().unwrap().wb.active().unwrap(); @@ -408,6 +420,8 @@ fn frozen_column_text_keeps_its_cell_when_scrolled() { (clips[0].left() - a1.left()).abs() <= 0.5 && (clips[0].right() - a1.right()).abs() <= 0.5, "A1's text spans A1 at column {col}: {clips:?} vs {a1:?}" ); + let visible = text_visible_rects(&h, LEFT); + assert!(visible.len() == 1 && visible[0].is_positive(), "A1's text shows inside its clip at column {col}: {visible:?}"); } }