3 Commits

Author SHA1 Message Date
5edc7c15da docs: record local.7 release verification 2026-11-11 14:38:34 +08:00
56a167d98c docs: prepare v1.4.2-local.7 release 2026-11-11 14:37:49 +08:00
6565352ab5 fix(editor): track dirty changes after the first autosave
CodeMirror 5 change handlers receive (instance, changeObj). The handler named the first argument change, so once the fold gutter populated __mdpFenceCache it threw on change.from.line before setDirty(true). Edits after the first autosave stayed clean: Ctrl+S and Ctrl+E skipped saving and the preview stayed stale. Use the correct signature, return early for remote setValue, and guard the cache update. Add a page regression test.
2026-11-11 14:19:16 +08:00
5 changed files with 86 additions and 7 deletions

View File

@@ -311,7 +311,7 @@ cargo test # 59 passed
- Gitea Release `v1.4.2-local.1`:https://git.wucl12.cn/wucl12/md-preview/releases/tag/v1.4.2-local.1 - Gitea Release `v1.4.2-local.1`:https://git.wucl12.cn/wucl12/md-preview/releases/tag/v1.4.2-local.1
- 附件 `MD-Preview-windows-x64.exe`(5,501,440 字节,SHA256 `F76BC396…BEDE96C`),发布说明见 `agent/docs/release-notes-v1.4.2-local.1.md`。 - 附件 `MD-Preview-windows-x64.exe`(5,501,440 字节,SHA256 `F76BC396…BEDE96C`),发布说明见 `agent/docs/release-notes-v1.4.2-local.1.md`。
- 发版流程:改版本 / 写 release notes → `build.ps1` → 用户在普通 PowerShell 运行 `publish.ps1` → 推 tag / 用 Gitea API 建 release 并上传 Nutstore 那份 exe。API 需要 `write:repository` scope 的 token,用完即删。 - 发版流程:改版本 / 写 release notes → `build.ps1` → 推 tag → 用 Gitea API 建 release 并上传 `target\release\md-preview.exe`(与 Nutstore 发布的是同一份字节)→ 用户在普通 PowerShell 运行 `publish.ps1`。API 需要 `write:repository` scope 的 token;token 位置 `C:\Users\wucl1\.gitea-token`,保留复用,不要打印/提交。
### 14.6 下一次开工检查 ### 14.6 下一次开工检查

View File

@@ -1,11 +1,13 @@
# 项目状态(滚动更新) # 项目状态(滚动更新)
> 最后更新:2026-11-03 > 最后更新:2026-11-11
> 用途:上下文压缩/交接后快速恢复。详细背景见 AGENTS.md、HANDOFF.md、scan-2026-10-21.md、roadmap.md。 > 用途:上下文压缩/交接后快速恢复。详细背景见 AGENTS.md、HANDOFF.md、scan-2026-10-21.md、roadmap.md。
> >
> **当前(2026-11-03):仓库根 `D:\Scripts\md-preview\AgentLowWorking`,整棵树 Low、DSH workspace-write 可编译;成品只发布到 Nutstore;仓库内 exe 已删除。功能基线 v1.4.2-local.5 + 本地未发布修复(59 tests);仓库已是 Windows-only。** > **当前(2026-11-11):仓库根 `D:\Scripts\md-preview\AgentLowWorking`,整棵树 Low、DSH workspace-write 可编译;成品只发布到 Nutstore;仓库内 exe 已删除。功能基线 v1.4.2-local.7(64 tests);仓库已是 Windows-only。**
> >
> 2026-11-03 已做:编辑模式与滚动位置按标签记忆;不再把 `.txt` 当文档;clippy 清零、`cargo fmt` 通过;AGENTS 允许拆模块/新增文件;功能不变地拆出 page/markdown/escape/config 模块并删除 macOS/Linux 死代码。未做功能与下一步见 `docs/next-2026-11-03.md`。 > 2026-11-03 已做:编辑模式与滚动位置按标签记忆;不再把 `.txt` 当文档;clippy 清零、`cargo fmt` 通过;AGENTS 允许拆模块/新增文件;功能不变地拆出 page/markdown/escape/config 模块并删除 macOS/Linux 死代码。未做功能与下一步见 `docs/next-2026-11-03.md`。
>
> 2026-11-11:修复 CodeMirror 5 编辑区回归(`change` 回调签名用错,第一次自动保存后不再置脏、`Ctrl+S`/`Ctrl+E` 不保存);发布 v1.4.2-local.7。
## 1. 仓库 ## 1. 仓库
@@ -176,7 +178,14 @@ cargo test
## 9. 发布(Gitea) ## 9. 发布(Gitea)
- 实例 Gitea 24.5.4,仓库私有。 - 实例 Gitea 24.5.4,仓库私有。
- Release `v1.4.2-local.5`(最新,2026-10-30):https://git.wucl12.cn/wucl12/md-preview/releases/tag/v1.4.2-local.5 - Release `v1.4.2-local.7`(最新,2026-11-11):https://git.wucl12.cn/wucl12/md-preview/releases/tag/v1.4.2-local.7
- 附件 `MD-Preview-windows-x64.exe`,5,760,000 字节
- SHA256 `318A27372FA5BF75746F102315BEDB87F131E769AE5BD40A4AA57C0B4CAD1652`(已从 Release 下载复核一致)
- 修复:CodeMirror 5 `change` 回调签名用错,第一次自动保存后输入不再置脏;正文来源 `agent/docs/release-notes-v1.4.2-local.7.md`
- Release `v1.4.2-local.6`(2026-11-06):https://git.wucl12.cn/wucl12/md-preview/releases/tag/v1.4.2-local.6
- 附件 5,759,488 字节;SHA256 `7421BFAF223C967AF40D02CBB5DFA3F354E87FA9847A3CAADDFAE553DC5FE860`
- 正文来源:`agent/docs/release-notes-v1.4.2-local.6.md`
- Release `v1.4.2-local.5`(上一版,2026-10-30):https://git.wucl12.cn/wucl12/md-preview/releases/tag/v1.4.2-local.5
- 附件 `MD-Preview-windows-x64.exe`,5,505,024 字节 - 附件 `MD-Preview-windows-x64.exe`,5,505,024 字节
- SHA256 `A632EF0363D04CE6F72B9779BA742681868AC31D36A7FE57E4F6D44E7BEAD988`(已下载复核一致) - SHA256 `A632EF0363D04CE6F72B9779BA742681868AC31D36A7FE57E4F6D44E7BEAD988`(已下载复核一致)
- 正文来源:`agent/docs/release-notes-v1.4.2-local.5.md` - 正文来源:`agent/docs/release-notes-v1.4.2-local.5.md`

View File

@@ -0,0 +1,40 @@
# v1.4.2-local.7(2026-11-11)
Windows 本地 Markdown 预览器,基于上游 md-preview 1.4.2 的离线定制版。本次修复 CodeMirror 5 编辑区的自动保存回归:第一次自动保存之后继续输入不再触发保存,`Ctrl+S` 和 `Ctrl+E` 也会跳过保存。
## 下载
- **MD-Preview-windows-x64.exe**
- 大小:5,760,000 字节
- SHA256:318A27372FA5BF75746F102315BEDB87F131E769AE5BD40A4AA57C0B4CAD1652
- 系统要求:Windows 10/11 x64;WebView2 Runtime(一般随系统自带)。
- 免安装:下载后放到固定目录直接运行;可在 .md 的“打开方式”里设为默认。
> exe 未签名,SmartScreen 可能提示未知发布者,选择“更多信息 → 仍要运行”。
## 本次修复
- **第一次自动保存后继续输入不保存**:CodeMirror 5 的 `change` 回调签名是 `(instance, changeObj)`,旧代码把第一个参数当成 change 对象。折叠缓存初始化后,每次输入都会在 `change.from.line` 抛异常,`setDirty(true)` 被跳过,标签保持 clean。
- 现象:新建或打开 md 后输入,第一次 700ms 自动保存把当时的内容写入文件;继续输入、手动 `Ctrl+S`、按 `Ctrl+E` 切预览都不会再保存,预览停留在第一次保存的内容。
- 修复:使用正确的 change 回调参数;把远程 `setValue` 的提前返回放到折叠缓存更新之前,并对 `change.from` 做存在性检查。
- 回归测试:`page::tests::editor_change_handler_uses_the_codemirror_instance_and_change_object`;另用 jsdom 对照旧/新页面,确认第二次输入会重新发出 `dirty:1`。
- 这是 `v1.4.2-local.6`(CodeMirror 5 编辑区)的回归修复,建议所有 local.6 用户升级。
## 包含上一版功能
- 编辑区使用内嵌 CodeMirror 5:行号、Markdown 着色、标题/代码围栏折叠;`Ctrl+F` / `Ctrl+H` 查找替换。
- 新标签页、多标签/多窗口、标签拖拽移出、同文件全局聚焦。
- 英文界面、标题折叠、`Ctrl+滚轮` 缩放、代码块始终深色、700ms 自动保存、外部修改热重载、单实例转发。
- GFM 脚注、定义列表、front matter、GitHub Alerts、`==高亮==`、KaTeX、Mermaid。
- UTF-8 BOM 容错与保存保留;新文件创建后直接进入编辑模式;相对图片/文档链接。
## 已知限制
- 编辑查找为字面匹配、大小写不敏感,不支持正则 `/re/`。
- 阅读→编辑的滚动位置按比例近似,但对齐到整行。
- 超过 2 MB 或 2 万行时编辑区回退纯 textarea(无行号/折叠/编辑查找)。
- 仅 Windows;不自动更新;升级请手动替换 exe。
## 从上一版升级
退出旧程序,用新 exe 覆盖原文件即可。设置、最近文件和缩放记录保存在 `%LOCALAPPDATA%\md-preview\`。

View File

@@ -746,11 +746,15 @@
return; return;
} }
ed = createCodeMirrorEditor(cm); ed = createCodeMirrorEditor(cm);
cm.on('change', function(change) { // CodeMirror 5 calls change handlers as (instance, changeObj). Naming the
if (cm.__mdpFenceCache) { // first argument `change` made `change.from` undefined; once the fold
// gutter had populated __mdpFenceCache this threw before setDirty(true),
// so edits after the first autosave never saved. Keep the object second.
cm.on('change', function(instance, change) {
if (applyingRemote) return;
if (cm.__mdpFenceCache && change && change.from) {
cm.__mdpFenceCache.validTo = Math.min(cm.__mdpFenceCache.validTo, change.from.line); cm.__mdpFenceCache.validTo = Math.min(cm.__mdpFenceCache.validTo, change.from.line);
} }
if (applyingRemote) return;
setDirty(true); setDirty(true);
scheduleAutosave(); scheduleAutosave();
updateDocumentStats(ed.value()); updateDocumentStats(ed.value());

View File

@@ -264,6 +264,32 @@ mod tests {
assert!(!page.contains("CodeMirror.defineMode")); assert!(!page.contains("CodeMirror.defineMode"));
} }
#[test]
fn editor_change_handler_uses_the_codemirror_instance_and_change_object() {
let strings = Strings::english();
let page = build_page(
&md_to_html("# Hello"),
"# Hello",
None,
EnhanceFlags::default(),
&strings,
false,
);
// CodeMirror 5 calls change handlers as (instance, changeObj). Using the
// first argument as the change object made change.from undefined; once
// the fold cache existed, the handler threw before setDirty(true), so
// edits after the first autosave were never marked dirty or saved.
assert!(page.contains("cm.on('change', function(instance, change) {"));
assert!(
page.contains(
"if (applyingRemote) return;\n if (cm.__mdpFenceCache && change && change.from) {"
),
"the remote guard must run before the fold-cache update"
);
assert!(!page.contains("cm.on('change', function(change) {"));
}
#[test] #[test]
fn edit_mode_find_bar_has_clickable_controls_and_no_escape_exit() { fn edit_mode_find_bar_has_clickable_controls_and_no_escape_exit() {
let strings = Strings::english(); let strings = Strings::english();