From 1cf81dcb44e16ad14bf527e9df7c2161fca95b83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=B7=E7=94=B5=E8=8A=BD=E8=A1=A3?= Date: Fri, 9 Oct 2026 02:39:47 -0400 Subject: [PATCH] Sheet scroll checks run on a real sheet with its geometry (R2.16) --- crates/ely-lok/src/view/tests.rs | 41 -------------------------- crates/ely-lok/src/view/tests/large.rs | 41 ++++++++++++++++++++++++++ tasks/reviews/R2.16-r2.md | 5 ++++ 3 files changed, 46 insertions(+), 41 deletions(-) create mode 100644 tasks/reviews/R2.16-r2.md diff --git a/crates/ely-lok/src/view/tests.rs b/crates/ely-lok/src/view/tests.rs index 62d5156..46ecb74 100644 --- a/crates/ely-lok/src/view/tests.rs +++ b/crates/ely-lok/src/view/tests.rs @@ -359,47 +359,6 @@ fn a_moved_cursor_scrolls_into_view_and_a_still_one_does_not() { view.scroll_by(0.0, 1_000_000.0, cx); view.apply_batch(batch(), None, cx); assert_eq!(view.scroll.1, 0, "a still cursor leaves the scroll alone"); - // Only a sheet grows past the kernel's size. - view.sheet = Some(crate::sheet::Geometry::default()); - let far = view.doc_size.1 + 20_000; - let cell = crate::Cell { - cursor: Some((1418, far, 1280, 277)), - ..crate::Cell::default() - }; - view.apply_batch( - crate::Events { - cell, - ..crate::Events::default() - }, - None, - cx, - ); - let height = view.geom.twips_of(view.viewport.1); - assert!( - view.scroll.1 <= far && far + 277 <= view.scroll.1 + height, - "a cell past the kernel's size still comes into view" - ); - view.scroll = (0, 0); - let width = view.geom.twips_of(view.viewport.0); - view.show((width - 200, 0, 1280, 256), cx); - assert!( - view.scroll.0 > 0 && width - 200 + 1280 <= view.scroll.0 + width, - "a cell cut at the right edge comes into view" - ); - view.scroll = (0, 0); - view.frozen = (0, 600); - view.show((1418, 300, 1280, 277), cx); - assert_eq!(view.scroll.1, 0, "a frozen row needs no scroll"); - view.show((1418, 9000, 1280, 277), cx); - let scrolled = view.scroll.1; - assert!(scrolled > 0, "a far row scrolls the rest"); - let row = view.place((0, 300)).y; - assert_eq!(f32::from(row), view.geom.px_of(300), "the frozen row stays"); - let far = view.twips_at(view.place((0, 9000))); - assert!( - (far.1 - 9000).abs() <= 15, - "a scrolled row maps back: {far:?}" - ); }); }); } diff --git a/crates/ely-lok/src/view/tests/large.rs b/crates/ely-lok/src/view/tests/large.rs index dfa1f12..1eb58e5 100644 --- a/crates/ely-lok/src/view/tests/large.rs +++ b/crates/ely-lok/src/view/tests/large.rs @@ -174,3 +174,44 @@ fn zooming_far_down_a_sheet_keeps_the_rows_in_view() { let after = middle(&mut cx); assert!(before.abs_diff(after) <= 1, "row {before} became {after}"); } + +#[test] +fn a_sheet_brings_far_cut_and_frozen_cells_into_view() { + let Some(install) = crate::client::tests::install() else { + eprintln!("SKIP: no pinned LOK build"); + return; + }; + let cx = gpui::TestAppContext::single(); + cx.update(|app| { + let (view, worker) = live_view_of(app, &install, "short.fods", SHORT_ROWS); + let json = worker.lock().expect("the worker lock").values(&view.read(app).doc, crate::sheet::GEOMETRY).expect("geometry"); + view.update(app, |view, cx| { + view.set_geometry(crate::sheet::geometry(&json).expect("parsed"), cx); + view.viewport = (800.0, 200.0); + let (width, height) = (view.geom.twips_of(view.viewport.0), view.geom.twips_of(view.viewport.1)); + let shows = |view: &LokView, rect: crate::Rect| { + let (x, y, w, h) = view.tile_rect(rect); + let (fx, fy) = view.frozen_tiles(); + x + w <= fx + view.scroll.0 + width && y >= fy + view.scroll.1 && y + h <= fy + view.scroll.1 + height + }; + let far = (1418, view.doc_size.1 + 20_000, 1280, 277); + let cell = crate::Cell { cursor: Some(far), ..crate::Cell::default() }; + view.apply_batch(crate::Events { cell, ..crate::Events::default() }, None, cx); + assert!(shows(view, far), "a cell past the kernel's size still comes into view"); + view.scroll = (0, 0); + let cut = (width - 200, 0, 1280, 256); + view.show(cut, cx); + assert!(view.scroll.0 > 0 && shows(view, cut), "a cell cut at the right edge comes into view"); + view.scroll = (0, 0); + view.set_frozen((0, 600), cx); + let frozen = view.place((0, 300)).y; + view.show((1418, 300, 1280, 277), cx); + assert_eq!(view.scroll.1, 0, "a frozen row needs no scroll"); + view.show((1418, 9000, 1280, 277), cx); + assert!(view.scroll.1 > 0, "a far row scrolls the rest"); + assert_eq!(view.place((0, 300)).y, frozen, "the frozen row stays"); + let back = view.twips_at(view.place((0, 9000))); + assert!((back.1 - 9000).abs() <= 15, "a scrolled row maps back: {back:?}"); + }); + }); +} diff --git a/tasks/reviews/R2.16-r2.md b/tasks/reviews/R2.16-r2.md new file mode 100644 index 0000000..d20b222 --- /dev/null +++ b/tasks/reviews/R2.16-r2.md @@ -0,0 +1,5 @@ +FAIL + +crates/ely-lok/src/view/scroll.rs:53 — 新增 `self.sheet.is_some()` 条件后,现有滚动回归测试失败:`view/tests.rs:349` 用 Writer 视图作夹具,随后模拟表格光标越过内核尺寸,缺少工作表 geometry,滚动范围因此保持原尺寸,`:376` 的可见性断言失败。独立运行 `cargo test --offline -p ely-lok --features view --lib view::tests::a_moved_cursor_scrolls_into_view_and_a_still_one_does_not -- --exact --nocapture` 稳定退出 101;当前视图测试为 31 通过、1 失败。修复方向:将该测试的表格部分改用真实工作表并初始化 geometry,保留超出内核尺寸的光标可见性断言及 Writer 滚动断言。证据:`/tmp/r216-r2-view-current.log`、`/tmp/r216-r2-scroll-rerun.log`。 + +crates/ely-lok/src/view/scroll.rs:52 — 新增注释 `Only a sheet grows where it jumps; pages keep their size.` 共 11 个英文单词,超过 agents.md 的十词限制。运行 `python3 tests/scripts/comments.py` 退出 1,并定位此行。修复方向:将该注释缩短至十词以内。证据:`/tmp/r216-r2-comments-final.log`。