Compare commits
2
Commits
0b478701b5
...
0d3d3603c8
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0d3d3603c8
|
||
|
|
db9b3975fe
|
No files matched your search
@@ -22,6 +22,7 @@ ely-ui.workspace = true
|
||||
|
||||
[dev-dependencies]
|
||||
ely-ui = { workspace = true, features = ["test-support"] }
|
||||
ely-gpui-component = { workspace = true, features = ["test-support"] }
|
||||
env_logger.workspace = true
|
||||
image.workspace = true
|
||||
tempfile.workspace = true
|
||||
|
||||
@@ -272,15 +272,13 @@ impl Render for Navigator {
|
||||
if let Some(at) = self.outline.iter().position(|heading| heading.current) {
|
||||
outline = outline.current(at.to_string());
|
||||
}
|
||||
let this = this.clone();
|
||||
// The places shown: a reread may change the list.
|
||||
let places: Vec<_> = self.outline.iter().map(|heading| heading.rect).collect();
|
||||
let docs = self.docs.clone();
|
||||
outline
|
||||
.on_select(move |key, _, cx| {
|
||||
let at: usize = key.parse().expect("an outline index");
|
||||
let (to, docs) = {
|
||||
let navigator = this.read(cx);
|
||||
(navigator.outline[at].rect, navigator.docs.clone())
|
||||
};
|
||||
Navigator::jump(&docs, to, cx);
|
||||
Navigator::jump(&docs, places[at], cx);
|
||||
})
|
||||
.into_any_element()
|
||||
}
|
||||
|
||||
@@ -252,3 +252,54 @@ fn pdfs_export_a_range_and_locked_files_ask() {
|
||||
"the locked text opens"
|
||||
);
|
||||
}
|
||||
|
||||
/// The navigator alone as a window's view.
|
||||
struct Host(Entity<Navigator>);
|
||||
|
||||
impl gpui::Render for Host {
|
||||
fn render(&mut self, _: &mut gpui::Window, _: &mut gpui::Context<Self>) -> impl gpui::IntoElement {
|
||||
gpui::div().size_full().child(self.0.clone())
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn an_outline_click_goes_where_its_row_was_drawn() {
|
||||
let dir = tempfile::tempdir().expect("a temp dir");
|
||||
let mut cx = TestAppContext::single();
|
||||
let Some(docs) = docs(&mut cx, dir.path()) else {
|
||||
eprintln!("SKIP: no LOK build");
|
||||
return;
|
||||
};
|
||||
cx.update(ely_gpui_component::init_for_tests);
|
||||
crate::tests::blank(&mut cx, &docs);
|
||||
let navigator = cx.update(|app| docs.read(app).navigator.clone());
|
||||
let heading = |n: i32| ely_lok::review::Heading { text: format!("Part {n}"), level: 0, rect: (0, n * 100, 10, 10), current: false };
|
||||
cx.update(|app| navigator.update(app, |navigator, cx| {
|
||||
navigator.outline = vec![heading(1), heading(2), heading(3)];
|
||||
cx.notify();
|
||||
}));
|
||||
let (_, vcx) = cx.add_window_view(|_, _| Host(navigator.clone()));
|
||||
let target = |vcx: &mut gpui::VisualTestContext| vcx.update(|_, app| docs.read(app).going.map(|going| going.3));
|
||||
// Find where the drawn third row sits.
|
||||
let third = (0..120)
|
||||
.map(|step| gpui::point(gpui::px(40.), gpui::px(step as f32 * 4.)))
|
||||
.find(|at| {
|
||||
vcx.simulate_click(*at, gpui::Modifiers::none());
|
||||
target(vcx) == Some((0, 300, 10, 10))
|
||||
})
|
||||
.expect("the third row is drawn");
|
||||
vcx.update(|_, app| docs.update(app, |docs, _| docs.going = None));
|
||||
// The list shrinks; the click lands on the old frame.
|
||||
vcx.update(|window, app| {
|
||||
navigator.update(app, |navigator, cx| {
|
||||
navigator.outline.truncate(1);
|
||||
cx.notify();
|
||||
});
|
||||
let (position, modifiers, button) = (third, gpui::Modifiers::none(), gpui::MouseButton::Left);
|
||||
let down = gpui::MouseDownEvent { position, modifiers, button, click_count: 1, first_mouse: false };
|
||||
window.dispatch_event(gpui::PlatformInput::MouseDown(down), app);
|
||||
let up = gpui::MouseUpEvent { position, modifiers, button, click_count: 1 };
|
||||
window.dispatch_event(gpui::PlatformInput::MouseUp(up), app);
|
||||
});
|
||||
assert_eq!(target(vcx), Some((0, 300, 10, 10)), "the click goes where its row was");
|
||||
}
|
||||
+1
-1
@@ -52,7 +52,7 @@
|
||||
- [x] D-03 界面线程同步持 worker 锁读内核(样式、字体、书签、公式、分节名) — 后台读取,回来核对标签、视图与对话框请求号
|
||||
- [x] D-04 一条批注的时间读不出,全部批注与修订都不显示 — 逐条解析,读不出的批注写明作者与原因(AX 可读、可滚动),修订照留
|
||||
- [x] D-05 邮件合并某条记录失败时内核文档泄漏 — 失败的记录照样关闭内核文档,再传出首个错误
|
||||
- [ ] D-06 导航栏大纲点击按当前列表取下标,后台重读后可能越界
|
||||
- [x] D-06 导航栏大纲点击按当前列表取下标,后台重读后可能越界 — 点击按绘制时的列表跳转;补点击路径的回归测试
|
||||
- [ ] D-07 导航栏隐藏时仍随每次光标移动重读大纲与书签
|
||||
- [ ] D-08 Linux、Windows 上“打印…”可用,导出 PDF 后才报“此平台未构建”
|
||||
- [x] M-01 键入期间外部以相同内容重写文件,丢掉上次停顿之后键入的全部文字 — 先等页面送出未送的键;同文只接过文件与字节、标签为已保存;磁盘回到上次保存的文字时保留编辑并恢复自动保存;R1–R4 字节、自动保存、在途写入、已保存基线;R5 PASS
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
FAIL
|
||||
|
||||
apps/ely-doc/src/navigate/tests.rs:96 — D-06 缺少覆盖大纲选择回调的回归测试;现有导航测试直接调用 `docs.jump`,无法检测旧的 `navigator.outline[at]` 回归。“需要碰中后台重读”的时序可以确定性控制:真实 GPUI 窗口先绘制 3 个标题,在同一次应用更新里将列表缩至 1 项并 `notify`,接着向旧帧第三行派发 `MouseDown`/`MouseUp`。审查探针使用实际 `Outline` 组件及逐字提取的生产渲染分支:当前代码返回第三项原矩形 `(0, 300, 10, 10)`;恢复旧回调后以 `len=1, index=2` 越界终止。构建和现有 4 项导航测试通过,但此点击路径仍缺少项目内的自动保护。修复方向:将上述确定性事件顺序加入导航回归测试,断言点击仍跳到绘制时的第三项,并确认旧回调会使测试失败。小日志:`/tmp/ely-d06-r1-evidence/native.log`、`/tmp/ely-d06-r1-evidence/native-original.log`。
|
||||
@@ -0,0 +1,3 @@
|
||||
FAIL
|
||||
|
||||
apps/ely-doc/src/navigate/tests.rs:316 — 新增注释 `A reread shrinks the list; the click meets the old frame.` 共 11 个词,违反 agents.md 的单行至多 10 词规则。运行 `python3 tests/scripts/comments.py` 返回退出码 1,并精确报告此行;日志见 `/tmp/ely-d06-r2-evidence/comments.log`。修复方向:将该注释缩至 10 词以内,再运行注释检查。
|
||||
@@ -0,0 +1 @@
|
||||
PASS
|
||||
Reference in new issue
Block a user