2 Commits
Author SHA1 Message Date
ZacharyZhang-NY bc133169e3 Reviews for P-10 2026-10-10 00:02:40 -04:00
ZacharyZhang-NY 3d20036bff ElyPDF: a preview overtaken by an edit says so (P-10) 2026-10-10 00:02:40 -04:00
5 changed files with 42 additions and 2 deletions

No files matched your search

+30
View File
@@ -397,3 +397,33 @@ fn a_small_picture_on_text_under_a_page_form_still_aims() {
click(cx, &view, (140.0, 66.0));
assert!(matches!(cx.update(|_, app| view.read(app).aim), Some(Aim::Text { .. })), "the text, not the form around it");
}
#[test]
fn a_preview_overtaken_by_an_edit_says_so() {
use ely_gpui_component::primitives::Severity;
let dir = tempfile::tempdir().expect("a temp dir");
let mut cx = TestAppContext::single();
let (viewer, cx, view) = editing(&mut cx, dir.path());
// The window's toasts live on its root.
let root = cx.update(|window, app| {
let root = ely_ui::document_root(ely_platform::AppId::Pdf, viewer.clone().into(), &ely_ui::commands::FILE, Vec::new(), window, app);
viewer.update(app, |viewer, _| viewer.core.root = root.downgrade());
root
});
click(cx, &view, (80.0, 66.0));
type_in(cx, &viewer, "Hi world\nSecond line");
cx.update(|_, app| viewer.update(app, |viewer, cx| {
// A new font asks for a preview first.
viewer.edit_panel.update(cx, |panel, _| panel.font = "times".into());
viewer.write_text(false, cx);
// An edit lands before the preview answers.
if let Some(view) = viewer.active_view() {
view.update(cx, |view, _| view.version += 1);
}
}));
let changed = cx.update(|_, app| Viewer::text(app, "pdf.object.changed", &[]));
settle(cx, |app| root.read(app).toasts(app).iter().any(|(text, severity)| *severity == Some(Severity::Warning) && *text == changed));
frames(cx);
assert!(cx.update(|_, app| viewer.read(app).preview.is_none()), "no stale preview");
assert_eq!(cx.update(|_, app| view.read(app).edited), 0, "nothing written");
}
+7 -1
View File
@@ -71,7 +71,8 @@ impl Viewer {
let (asked, viewer) = (writing.clone(), cx.weak_entity());
view.update(cx, |view, cx| {
let doc = view.doc;
view.read(
// A stale answer still reaches `previewed`, which says so.
view.off(
move |worker| worker.put_text(doc, page, &asked, PREVIEW),
move |_, answer, cx| {
// The viewer edits this view; wait until it is free.
@@ -95,6 +96,11 @@ impl Viewer {
replacing: bool,
cx: &mut Context<Self>,
) {
let same = self.tab(tab).is_some_and(|open| open.view.read(cx).version == version);
if !same {
let text = Self::text(cx, "pdf.object.changed", &[]);
return self.toast(text, Severity::Warning, cx);
}
match answer {
Ok(Wrote::Unwritable) => {
let note = Self::text(cx, "pdf.text.unwritable", &[]);
+1 -1
View File
@@ -42,7 +42,7 @@
- [x] P-07 含连字的文字块永远不可编辑 — 字形按 stext 的写法展开(多字字形、连字码点),整页、单块与删除同一判法;R3 PASS
- [x] P-08 页面读取失败后每帧重试、每帧弹提示 — 失败的读取按页或种类记下,编辑后重读;签名读取以保存计数判过期
- [x] P-09 识别文字的写入被拒后仍弹“成功” — on_same 回报是否执行;被拒时只有警告
- [ ] P-10 预览回复被丢弃时“应用”静默无事
- [x] P-10 预览回复被丢弃时“应用”静默无事 — 预览回复照常交回,版本已变即提示,不显示过期预览
- [ ] P-11 撤销或重做在 MuPDF 侧失败后 worker 的步数不再同步
- [ ] P-12 `unhook` 中途抛出时泄漏保留的对象
- [ ] P-13 优化导出的“之前”大小取磁盘文件而非当前文档
+3
View File
@@ -0,0 +1,3 @@
FAIL
apps/ely-pdf/src/tests/editing.rs:414 — 回归测试覆盖不到新增的 `previewed` 版本守卫。这里保持原字体并缩短文字,回复进入 `commit_text`,已有的 `on_same` 也会发出相同警告。复现:在独立副本中保留 `view.off`,仅删除 `writes.rs:99-103` 的版本检查,18 个文字编辑测试仍全部通过;同一竞态中将字体设为 `times`,过期回复会展示布局预览且缺少警告,补充探针以 `stale layout preview was presented` 失败。恢复守卫后两个竞态探针均通过,原实现的全部 131 个 ElyPDF 测试通过。修复方向:让本用例通过字体变更或文字增长进入布局预览分支,同时断言 `pdf.object.changed` 警告、`preview.is_none()` 和写入计数。证据:`/tmp/ely-p10-r1-evidence.log`;可重建探针:`/tmp/ely-p10-r1-probe-source.log`。探针副本及独立构建目录已删除。
+1
View File
@@ -0,0 +1 @@
PASS