Inverted CheckRuleFiles condition in SpeechRules::replace_single_char causes unicode-full.yaml to reload when CheckRuleFiles is "None"
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 1/5
- 预计耗时
- 1 小时以内
- 新手友好度
- 84/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- rust
调研方向
阅读 src/speech.rs,并将 SpeechRules::replace_single_char 中的 CheckRuleFiles 条件与 SpeechRules::update 和 read_files 中的检查进行比较。按照 issue 中的描述修改该条件,然后运行与规则文件加载和单字符替换相关的测试。当 "None" 忽略文件时间戳,且 "All" 仍能检测到文件更改时,即为完成。
由索引模型根据 Issue 内容生成。
描述
Summary
In src/speech.rs, SpeechRules::replace_single_char has an inverted equality check when computing should_ignore_file_time:
let should_ignore_file_time = pref_manager.pref_to_string("CheckRuleFiles") == "All";
Every other rule loader in src/speech.rs (such as SpeechRules::update and read_files) uses != "All":
let should_ignore_file_time = pref_manager.pref_to_string("CheckRuleFiles") != "All";
Impact
- When
CheckRuleFiles: "None"(recommended for environments where rule files are static or loaded from in-memory archives/zip files):should_ignore_file_timeevaluates tofalseinstead oftrueinsidereplace_single_char.is_file_up_to_datechecks the file's modification timestamp on every character lookup that falls back tounicode-full.yaml(such as Mathematical Italic characters𝑥, 𝑎, 𝑏, 𝑐after canonicalization).- In environments where rule files are backed by an in-memory filesystem or lack valid modification timestamps (returning
UNIX_EPOCH),is_file_up_to_datereturnsfalseon every call, causing MathCAT to re-parse the ~6,500-entryunicode-full.yamlfile on every single character lookup (~30ms per character on mobile devices, adding 200–480ms of latency per expression or navigation step).
- When
CheckRuleFiles: "All":should_ignore_file_timeevaluates totrue, so edits tounicode-full.yamlare ignored instead of being reloaded.
Proposed Fix
In src/speech.rs inside SpeechRules::replace_single_char, change == "All" to != "All":
- let should_ignore_file_time = pref_manager.pref_to_string("CheckRuleFiles") == "All";
+ let should_ignore_file_time = pref_manager.pref_to_string("CheckRuleFiles") != "All";
- 主要语言
- Rust
- 星标
- 131
- 派生
- 97
- 平均合并
- 21 小时 45 分钟
- 30 天内合并 PR
- 95
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
daisy/MathCAT 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 88/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 88/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 82/100
ElectronicWave/Elemental#252 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 78/100
dekobon/big-code-analysis#1887 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 82/100
维护者通常 1 天内回复
-
area:mcp effort:low P5 source:agent
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 70/100
jlcodes99/cockpit-tools#3103 ·
维护者通常 2 天内回复