fix(patch): 渲染层增加工作区内容禁区,代码与文件名不再被汉化 - #3
Merged
Conversation
词典含单词级 exact 词条(cloud/text/a/New 等),而注入脚本此前始终扫描 document.body:Monaco 把每行代码按 token 切成独立文本节点,代码里的 cloud/text、<a /> 的 a、文件树里名为 cloud 的文件夹都会与词条精确撞车 (issue #2 的三个截图症状)。纯删词条治不了这一类问题——cloud→云端 本身是正当的界面词条。 修法是在 TreeWalker 过滤器(所有文本翻译的必经之路)加一层禁区检查: 文本节点的祖先命中 NO_TRANSLATE_SELECTOR 即拒绝翻译。禁区覆盖 .view-lines(主编辑器/diff/聊天代码块/Notebook 的代码渲染)、 .explorer-folders-view(文件树)、.search-view .results(搜索结果)、 .xterm-rows(终端输出)、.monaco-breadcrumbs(面包屑路径与符号)。 输入框 placeholder/title/aria-label 的属性翻译路径不受影响。 ponytail 局限:标签页标题、Open Editors、快速打开(Ctrl+P)里的文件名 若恰好与词条全等仍会被翻译,属混合 UI 区,暂不做精确切分;出现实例时 再把对应容器加入禁区列表即可。 Fixes #2 Generated-by: GLM-5.3-Flash (ZCode)
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
修复 #2:词典里的单词级 exact 词条(cloud/text/a 等)撞上了编辑器代码 token 与文件名——Monaco 把每行代码按 token 切成独立文本节点,
text→文本、<a />→<一个 />、Java 包cloud→云端都是这么来的。删词条治不了这一类问题(cloud→云端本身是正当的界面词条),所以在渲染层注入脚本的文本节点过滤器(所有文本翻译的必经之路)加了一层「工作区内容禁区」:命中.view-lines(编辑器/diff/聊天代码块/Notebook)、.explorer-folders-view(文件树)、.search-view .results(搜索结果)、.xterm-rows(终端)、.monaco-breadcrumbs(面包屑)的文本一律不翻译;输入框 placeholder/title/aria-label 的属性翻译路径不受影响。已知边界(暂不处理):标签页标题、快速打开(Ctrl+P)里的文件名若与词条完全相同仍会被翻译——这些是 UI 与文件名混合的区域,出现实例时把对应容器加进禁区列表即可。
另含两个小 commit:lockfile 里扩展 workspace 版本号同步(0.0.4→0.0.6→0.0.7)、0.0.7 版本号与 CHANGELOG 准备。
Fixes #2
Verification
.view-lines容器里的text、.explorer-folders-view里的cloud保持原样window.__cursorZhPatch={active: true, count: 1506}npm test(vitest 15 项,含 2 项新增禁区契约测试)npm run build+npm run build:ext(tsc 编译)AI use
Tool(s) and scope: GLM-5.3-Flash (ZCode) —— 根因定位、修复实现、实机验证、词典构建与本文档均由 AI 完成;ggbdpq 复核后合并。
Checklist