Skip to content

[1282] 将 shortcut-edit.scm 的 JSON 库从 njson 迁移至 (liii json) - #4521

Merged
da-liii merged 2 commits into
mainfrom
da/1282/shortcut_json
Sep 8, 2026
Merged

[1282] 将 shortcut-edit.scm 的 JSON 库从 njson 迁移至 (liii json)#4521
da-liii merged 2 commits into
mainfrom
da/1282/shortcut_json

Conversation

@da-liii

@da-liii da-liii commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

任务描述

shortcut-edit.scm 中取消对 (liii njson) 的依赖,直接改用 (liii json) 处理 Scheme 原生 JSON 数据结构(alist 与 vector)。采用 TDD 方式新增 shortcut-edit-test.scm 单元测试,驱动并验证重构。

变更内容

  1. 测试先行(TDD)
    • 新增 TeXmacs/progs/source/tests/shortcut-edit-test.scm,全面覆盖快捷键条目结构校验、合法/非法 JSON 模式验证、CRUD 操作、排序查询、旧版 .scm 兼容迁移合并以及文件持久化与异常回退(共 54 个断言)。
  2. 取消 njson 依赖
    • (import (liii njson)) 替换为 (import (liii json)).
    • 移除 njson-freenjson-schema-reportfile->njsonnjson->file 等 C++ 句柄操作与 schema 校验,改用纯 Scheme 原生数据结构与 (liii json) 谓词校验。
    • 文件存取使用 string-savestring-load 配合 json->stringstring->json,移除仅供 C++ handle 访问使用的 user-shortcuts-file-system
  3. 任务文档
    • 新增 devel/1282.md,记录 What/Why/How 及自动化单元测试与手工 GUI 测试步骤。

如何测试

1. 纯逻辑单元测试(自动化,headless)

xmake b stem && xmake r shortcut-edit-test    # 54 correct, 0 failed

2. 手动测试(GUI)

详见 devel/1282.md 第 3.2 节:

  • 通过菜单 工具 -> 键盘 -> 编辑键盘快捷键 打开快捷键编辑器;
  • 新增快捷键并在文档中测试触发;
  • 检查 $TEXMACS_HOME_PATH/system/shortcuts.json 的标准 JSON 格式;
  • 重启验证快捷键持久化有效;
  • 删除快捷键并验证移除;
  • 模拟非法/损坏 JSON 配置,验证异常容错与安全重置。

@MoonL79 MoonL79 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@da-liii
da-liii merged commit 7121062 into main Sep 8, 2026
3 checks passed
@da-liii
da-liii deleted the da/1282/shortcut_json branch September 8, 2026 06:11
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.

2 participants