Skip to content

[4466] 修复 Windows 下清空最近文件后重启又全部回来:迁移标记文件名含非法字符 '>' - #4703

Open
bnspopi wants to merge 1 commit into
MoganLab:mainfrom
bnspopi:bnspopi/200_27/fix_recent_files_migration_marker
Open

bnspopi wants to merge 1 commit into
MoganLab:mainfrom
bnspopi:bnspopi/200_27/fix_recent_files_migration_marker

Conversation

@bnspopi

@bnspopi bnspopi commented Oct 11, 2026

Copy link
Copy Markdown

问题

Fixes #4466(#4404 子问题)。Windows 下清空最近文件当场生效,重启后旧条目全部回来。

根因

不是清空逻辑或落盘时机的问题,而是启动时的旧数据迁移。tm-dialogue.scm 用标记文件判断 interactive.scm 是否已迁移到 JSON,文件名是 interactive.scm->v1 / recent-files.scm->v1。Windows 文件名禁止 < > : " | ? *,所以 write-migration-marker 永远写不出该文件,url-exists? 永远 #f,maybe-import-legacy-scm-interactive-state 每次启动都把 interactive.scm 里的旧 recent-buffer 重新灌进 recent-files.json。macOS/Linux 允许 >,首次即落盘,故只有 Windows 复现。本机 Windows 11 用 PowerShell 验证含 > 的路径直接报 Illegal characters in path。

shortcut-edit.scm 的 shortcuts.scm->v1 同类问题(删掉的自定义快捷键每次启动回灌),一并修。

改动

  • tm-dialogue.scm:标记改名 *.scm.migrated-v1;旧名保留为 legacy 标记,新增 migration-marker-exists?,新旧任一存在即视为已迁移,macOS/Linux 已迁移用户不会再导入一次。write-migration-marker 与标记路径改 define-public 供测试。导入流程未动。
  • shortcut-edit.scm:同样处理。
  • tm-dialogue-test.scm:新增 headless 测试(xmake r tm-dialogue-test)——标记文件名不含 Windows 非法字符;用真实标记名在临时目录写入后 url-exists? 为 #t(旧名在 Windows CI 必红);新旧标记任一存在即判定已迁移。

影响

Windows 用户升级后首次启动最后执行一次迁移,标记落盘,之后清空/移除都能跨重启保持。

未做

  • 清空只改内存、靠 on-exit 写回,崩溃时会丢;是另一类问题,不混入本 PR。
  • 本机无 xmake/gf,未能本地跑测试与 gf fmt,烦请以 CI 为准。改动全在 Scheme 层。

🤖 Generated with Claude Code

根因:旧数据迁移标记 interactive.scm->v1 / recent-files.scm->v1 的文件名含 '>',
而 Windows 文件名禁止 < > : " | ? *。string-save 写不出该文件,url-exists?
永远为 #f,于是 maybe-import-legacy-scm-interactive-state 在每次启动都判定
「未迁移」,把 $TEXMACS_HOME_PATH/system/interactive.scm 里的旧 recent-buffer
条目重新导入 recent-files.json。用户在启动页或 文件→最近 清空列表后,
一重启旧条目全部回来。macOS/Linux 文件名允许 '>',标记首次即落盘,故不受影响。

修复:
- tm-dialogue.scm:标记改名为 interactive.scm.migrated-v1 /
  recent-files.scm.migrated-v1;保留旧名作为 legacy 标记,新旧任一存在即视为
  已迁移(migration-marker-exists?),避免 macOS/Linux 已迁移用户再导入一次。
- shortcut-edit.scm:shortcuts.scm->v1 同类问题,同样处理(否则 Windows 下
  用户删除的自定义快捷键每次启动都会从 shortcuts.scm 回灌)。
- tm-dialogue-test.scm:新增 headless 测试——标记文件名不含 Windows 非法字符;
  用真实标记文件名在临时目录写入后 url-exists? 为 #t(旧名在 Windows 上必红);
  新旧标记任一存在即判定已迁移。

Fixes MoganLab#4466

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

“Clear all” works initially, but after restarting the application, all recent files reappear.

1 participant