From 6145b5cea22223f41aa16482d1d6f9a4c8fec892 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 18:42:39 -0400 Subject: [PATCH] ElyTable: a large text file no longer freezes the window before its import dialog (T-09) --- apps/ely-table/src/text.rs | 15 +++++++++------ tasks/BUGS.md | 2 +- tasks/reviews/T-09-r1.md | 1 + 3 files changed, 11 insertions(+), 7 deletions(-) create mode 100644 tasks/reviews/T-09-r1.md diff --git a/apps/ely-table/src/text.rs b/apps/ely-table/src/text.rs index b517c4b..2b6a08d 100644 --- a/apps/ely-table/src/text.rs +++ b/apps/ely-table/src/text.rs @@ -235,13 +235,16 @@ impl Book { let reading = path.clone(); let chinese = ely_ui::i18n::resolve(&ely_platform::locale::system()) == "zh-CN"; cx.spawn(async move |this, cx| { - let bytes = cx - .background_spawn(async move { std::fs::read(&reading) }) + // Guessing checks the whole file: off the window thread. + let pending = cx + .background_spawn(async move { + std::fs::read(&reading).map(|bytes| Pending::new(reading, bytes, chinese)) + }) .await; - in_window(&this, cx, |book, _, cx| match bytes { - Ok(bytes) => { - log::info!("table: import asks for {} bytes", bytes.len()); - book.imports.push_back(Pending::new(path, bytes, chinese)); + in_window(&this, cx, |book, _, cx| match pending { + Ok(pending) => { + log::info!("table: import asks for {} bytes", pending.bytes.len()); + book.imports.push_back(pending); book.next_import(cx); } Err(error) => book.failed_open(&path.display().to_string(), &error, cx), diff --git a/tasks/BUGS.md b/tasks/BUGS.md index e45637b..bfca13e 100644 --- a/tasks/BUGS.md +++ b/tasks/BUGS.md @@ -16,7 +16,7 @@ - [x] T-06 滚轮向下被内核平铺区卡住 — 表格的可滚范围先行两屏、止于表尾;R1 PASS - [x] T-07 表头点选、行高列宽拖动是“按编号的命令”,而每次点击与拖选都推进修订,紧接着的表头操作被当作过期拒绝 — 行列号不再算作按编号的命令;R1 PASS - [x] T-08 自动筛选的列菜单对光标所在的表而不是按钮所在的表筛选、排序 — 先把光标移到按钮所在格再排序或筛选;R1 PASS -- [ ] T-09 导入文本文件时整文件的 UTF-8 校验在界面线程跑 +- [x] T-09 导入文本文件时整文件的 UTF-8 校验在界面线程跑 — 编码与分隔符的猜测随读文件在后台;R1 PASS - [ ] T-10 CSV 导入对话框开着时打开任何别的对话框,待导入的文件静默消失 - [ ] T-11 对话框比其标签活得久:导出、定义名称、重命名不可见却“开着”,挡住导入;名称表的“转到”激活已关闭的标签 - [ ] T-12 打印区域是整列或整行时页面设置无法应用 diff --git a/tasks/reviews/T-09-r1.md b/tasks/reviews/T-09-r1.md new file mode 100644 index 0000000..7ef22e9 --- /dev/null +++ b/tasks/reviews/T-09-r1.md @@ -0,0 +1 @@ +PASS