Inverted CheckRuleFiles condition in SpeechRules::replace_single_char causes unicode-full.yaml to reload when CheckRuleFiles is "None"

未关闭 适合新手
#996 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
1/5
预计耗时
1 小时以内
新手友好度
84/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
rust
领域
accessibility

调研方向

阅读 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
  1. When CheckRuleFiles: "None" (recommended for environments where rule files are static or loaded from in-memory archives/zip files):
    • should_ignore_file_time evaluates to false instead of true inside replace_single_char.
    • is_file_up_to_date checks the file's modification timestamp on every character lookup that falls back to unicode-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_date returns false on every call, causing MathCAT to re-parse the ~6,500-entry unicode-full.yaml file on every single character lookup (~30ms per character on mobile devices, adding 200–480ms of latency per expression or navigation step).
  2. When CheckRuleFiles: "All":
    • should_ignore_file_time evaluates to true, so edits to unicode-full.yaml are 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 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

daisy/MathCAT 的其他 Issue

查看 daisy/MathCAT 的全部 Issue

相似的 Issue

更多 Rust Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。