Repository navigation
fix(editor): 行注释符号改由语言注册表提供,插件声明的 lineComment 生效 (#1856) - #2036
Merged
Merged
Conversation
Core 删除了 editor.lineCommentToken 和写死的扩展名→注释符号表(#1856 第 5 项)。 桌面端改为从编辑器语言注册表取行注释符号: - syntax.Registry.CommentsForPath:按 ForPath 选出的语言返回注释符号;只为 服务器或调试器认领文件、既无语法也无注释的插件语言,沿用按文件名选出的 内置语言的注释(与 SyntaxForPath 沿用配色一致)。 - 内置语言补齐旧 Core 表覆盖、注册表缺失的扩展名:haskell(.hs)、 objective-cpp(.mm)、perl(.pl/.pm),ini 增加 .cfg/.conf,dotenv 增加 .env 后缀。 - workbench.runLineOperation 切换注释前同步取符号,没有时提示 desktop.editor.noLineComment,不再多一次 Core 调用。 - 删除 core.LineCommentToken 及其测试;TestCommentsForPath 覆盖旧表的全部扩展名。 - .json 现在按内置表使用 //(与 VS Code 一致),此前 Core 返回空。 - PINNED_CORE_REVISION 暂指 Core 分支 commit 12d3739,Core PR 合入后换成 main 上的 squash commit。 - 重写行操作 Agent Note,更新功能矩阵说明与证据。
插件内容文档的 path 是 URI,文件名只在 name 里;打开文档时 ForPath 也按 name 选语言。
Haskell 名字里的 ' 表示撇号(如 foldl'),不是字符串定界符。
28 of 33 tasks
xiaoyumuxi
marked this pull request as ready for review
November 16, 2026 11:50
Owner
|
说明一下 main 上的 Core 固定版本:#2040 已经合入 main, 本 PR 把固定版本换成 Core main 上 #66 的 squash commit 时,会和这一行冲突。冲突时直接用最新的 Core main 即可:Core #67 已经以 这样之后 main 的固定版本就回到 Core main 上的 commit 了。#67 的分支 |
…mment-from-language-registry # Conflicts: # scripts/desktop/build-desktop-core.sh
9 of 12 tasks
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.
关联 Issue / Linked issue
本 PR 只完成 #1856 的第 5 项(行注释符号表),对应的 Core 改动在 Lithe-IDEA/Lithe-core-rust#66 。第 1–4 项(忽略目录名单、rust-analyzer/gopls 索引排除、go/node 运行时、运行发现探测器)不在本 PR,#1856 保持打开。
PR 类型 / Type
改动说明 / What changes
背景 / Why
切换行注释(Primary+/ 和右键菜单)时,桌面端会先调 Core 的
editor.lineCommentToken取注释符号。Core 用一张写死的“扩展名 → 符号”表回答。这张表的问题:languages[].configuration.lineComment里声明的符号不会生效。插件新增的语言切换注释时只会提示“没有行注释”。desktop/internal/editor/syntax/languages.go)是两份数据,已经不一致:例如.json在注册表里用//,在 Core 表里没有。#1856 建议让 Core 从插件清单解析注释符号。本 PR 换了做法:Core 删除这个命令,桌面端直接用已有的语言注册表。注册表已经合并了内置语言和插件
languages[]声明,文件到语言的匹配规则(扩展名、文件名、前缀、同 ID 覆盖)也都在注册表里。再让 Core 解析插件清单,等于把匹配规则复制一份到 Core。改动 / Changes
语言注册表(
desktop/internal/editor/syntax/)language.go:新增Registry.CommentsForPath(name),返回ForPath给这个文件选出的语言的注释符号。clangd认领 C/C++/Objective-C 文件),就沿用按文件名选出的内置语言的注释。这和SyntaxForPath沿用内置配色的规则一致,否则装了这类插件后.c文件会失去//。languages.go:补齐旧 Core 表覆盖、注册表缺失的扩展名,保证迁移后不丢符号:haskell(.hs,--/{- -})、objective-cpp(.mm,//)、perl(.pl、.pm,#)。三个都没有语法,不着色。Haskell 的自动闭合不配对',因为 Haskell 名字里的'是撇号(如foldl')。ini增加.cfg、.conf;dotenv增加.env后缀(如prod.env)。language_test.go:新增TestCommentsForPath,覆盖://类 26 个、#类 18 个、--类 3 个;README.md、site.css、未知扩展名、空名;行操作(
desktop/internal/workbench/lineedit.go)runLineOperation在窗口线程上用CommentsForPath(d.name)同步取符号,之后只调用一次 Core(editor.lineEdit)。没有符号时直接提示desktop.editor.noLineComment,不再进入后台。editorKernel接口删除LineCommentToken。Core 桥接(
desktop/internal/core/)line_edit.go:删除Client.LineCommentToken。line_edit_test.go:删除TestLineCommentTokenUsesCoreLanguageTable,以及 fixture 测试里处理查符号用例的分支(Core 已删除这些用例)。行变换 fixture 测试和BenchmarkCoreToggleLineComment保留。Core 固定版本(
scripts/desktop/build-desktop-core.sh)PINNED_CORE_REVISION指向 Core main5a8d786。它包含 fix: resolve Swift 6.2 pointer modifier isolation #66(删除行注释表)的 squash commit,以及在它之后合入 main 的 [Bug] LSP部分正常的启动跳转功能没有完善,可能有问题 #68(语言服务器声明 indexingExclusions)和 lithe 0.2.0 #67(工具链候选列出 JAVA_HOME 与 PATH 指向的安装)。分支合并了桌面端 main(含 feat(desktop): 多仓库文件夹接入 Core,分支入口与 Git Log 按 IDEA 样式按仓库操作 #2038、fix(desktop): Viva 升级到上游 b17e605,应用更新与插件市场下载断点续传 #2039)后,按 main 的最新固定版本更新。Agent Note 与功能矩阵
.agents/notes/implemented/architecture/2026-11-08-viva-line-edit-core-bridge.md:整篇按现状重写。旧版还写着“Core 维护语言表”;现在写的是 Core 只负责变换规则,CommentsForPath是注释符号的唯一来源(含回退规则),以及有界窗口、接线、被否的方案、.json行为变化和验证命令。shared/platform-feature-matrix/features/editor-line-operations.json:说明改为“注释符号取自编辑器语言注册表”;macOS 和 Windows 的证据都加上language.go和language_test.go。验证状态仍是pending。用户可观察的变化
configuration.lineComment)按 Primary+/.json按 Primary+///(内置表的值,与 VS Code 一致).cfg、.conf#(之前 Core 表也给#)prod.env这类.env后缀文件.hs、.mm、.pl、.pmhaskell、objective-cpp、perl),按这些 ID 声明的插件语言服务器可以接管;注释符号不变TestCommentsForPath逐个固定语言的
Brackets和AutoClosing目前只是存储和合并,编辑器还没有读取,所以新增语言不会改变括号行为。不在本 PR 范围内 / Out of scope
类型专属:fix
复现与根因
languages[]里声明lineComment: ";;"的插件,打开它认领的文件,按 Primary+/。实际:提示“没有行注释”。期望:行首加上;;。.json文件同样提示没有行注释,期望用//。editor.lineCommentToken),不读语言注册表。行操作接入 Core 时(2026-11-08-viva-line-edit-core-bridgeNote)就是这样设计的。检查项
TestCommentsForPath的插件用例(;;生效、同 ID 继承、无语法插件回退)。修复前没有CommentsForPath,测试无法编译;行为上修复前切换注释只查 Core 表,插件声明的;;不会生效。修复后scripts/desktop/desktop-go.sh test ./internal/editor/syntax -count=1通过。git grep -i lineCommentToken只剩build-desktop-core.sh的固定版本说明;Windows 和 macOS 共用desktop/;插件和 SDK 不调用editor.*命令;Core 侧在 fix: resolve Swift 6.2 pointer modifier isolation #66 删除。2026-11-08-viva-line-edit-core-bridge.md(架构决策,不放 bug-fix 目录)。范围检查 / Scope checks
功能矩阵 / Feature matrix
shared/platform-feature-matrix/features/editor-line-operations.json:说明和证据路径已更新,两端验证状态保持pending./scripts/platform-feature-matrix/verify-platform-feature-matrix.sh和./scripts/platform-feature-matrix/verify-platform-feature-matrix-change.sh origin/main HEAD.artifacts/下生成的矩阵视图插件归属 / Plugin ownership
develop-lithe第三节的自查命令,结果为空demo、go、clangd、own),没有读取真实插件包、仓库或清单languages[].configuration.lineComment是已有契约字段,本 PR 只是让宿主真正读取它,不改契约UI 验证 / UI evidence
N/A:没有布局、控件、样式或文案变化。提示文案
desktop.editor.noLineComment沿用原有词条,只改变了何时出现(见上方行为变化表)。统一日志系统 / Structured logging
N/A:没有新增或改动生命周期、终态或失败路径。删除的是“取符号失败”这条 Core 调用路径;
editor.lineEdit的失败处理(lineEditFailed)没变。界面文案 / i18n
desktop.editor.noLineCommentnode scripts/i18n/verify-app-language-localization.mjs和node scripts/i18n/generate-i18n.mjs --check逻辑归属 / Logic placement
editor.lineEdit。“文件属于哪种语言、用什么注释”属于语言注册表:内置语言在桌面端,插件语言在插件清单。Core 不再含语言表。clangd回退是按“无语法、无注释”的通用条件判断,不按名字。性能与内存 / Performance and memory
ForPath加一次比较),比原来多一次后台 Core 调用更省;没有文件读写editor.lineEdit的输入窗口和调用方式没变,所以不需要改动前后的性能基线设置 / Settings
N/A:没有设置项变化。
插件契约 / Plugin contract
editor.lineCommentToken是宿主 C ABI 命令,Core fix: resolve Swift 6.2 pointer modifier isolation #66 不涉及shared/plugins/PINNED_CORE_REVISION已升到 Core main5a8d786,包含删除改动的 fix: resolve Swift 6.2 pointer modifier isolation #66 squash commit;桌面端全量测试读到的就是这个版本发行包与资源 / Bundle and resources
./scripts/desktop/verify/verify-runtime-bundle-immutability.sh无用代码与重构 / Dead code and refactoring
Client.LineCommentToken、接口方法和测试已删除验证 / Verification
LITHE_CORE_RUST_DIR=<Core 分支检出> scripts/desktop/desktop-go.sh test ./internal/core ./internal/editor/syntax ./internal/workbench -count=1 -timeout=900sscripts/desktop/desktop-go.sh vet ./...(当时固定的分支 commit)scripts/desktop/desktop-go.sh test ./...(合并桌面端 main、固定 Core main5a8d786之后)scripts/desktop/desktop-go.sh test ./internal/workbench -run '^Test(LineOperationKeys|LineOperationsThroughCore|EditorContextMenuRunsLineOperation)$'(改为按文档名查之后)scripts/desktop/desktop-go.sh test ./internal/editor/syntax -count=1(Haskell 配对修改之后)node scripts/i18n/verify-app-language-localization.mjs、node scripts/i18n/generate-i18n.mjs --check./scripts/desktop/verify/verify-runtime-bundle-immutability.sh./scripts/agent-notes/verify-agent-notes.sh./scripts/platform-feature-matrix/verify-platform-feature-matrix.sh./scripts/platform-feature-matrix/verify-platform-feature-matrix-change.sh origin/main HEADdevelop-lithe第三节插件归属自查rgcargo test -p lithe-editor -p lithe-core、全 workspacecargo clippy -D warnings、注释规范、平台测试检查接手合并(2026-11-16):合入 main(含 #2040)后,
build-desktop-core.sh的固定版本和 #2040 冲突。#2040 固定的是 Core #67 分支 commit16d17b1,本 PR 固定的是 Core main5a8d786,后者已同时包含 #66、#67、#68,所以保留5a8d786,并把 #67 的说明补全。合并后在 macOS arm64 上重新验证:scripts/desktop/desktop-go.sh test ./... -count=1(链接 Core5a8d786)node scripts/desktop/validate-pins.mjsmake fmt-check、i18n 两项检查、功能矩阵两项检查、verify-agent-notes.sh上一轮 CI 中 Linux 和 Windows 的失败(
TestKeymapAddRecordsTheChordPressedAfterIt,以及 Linux 上终端集成的两个 bash 测试)在 main 上同样失败,与本 PR 无关;前者由 #2041 修复。未能执行的检查和原因:
.json、.c按 Primary+/。功能矩阵两端的验证状态保持pending。提交前确认 / Final checks
main(cad565600)创建,目标分支main