Repository navigation
refactor(editor): 删除 Core 的行注释符号表,注释符号由宿主语言注册表提供 - #66
Merged
Merged
Conversation
editor.lineCommentToken 用一张写死的扩展名/语言 ID 表回答行注释符号, 违反 Core 对语言零特判的约束(Lithe-IDEA#1856 第 5 项)。宿主的语言注册表 (内置语言与插件 languages[].configuration.lineComment)已经声明每种语言的 注释,这张表是重复的第二份来源。 - 删除 editor.lineCommentToken 命令、LineCommentTokenRequest/LineCommentToken 类型和 line_comment_token 查表函数 - editor.lineEdit 不变,toggleLineComment 仍要求调用方传 commentToken - 共享夹具 line-edit-v1.json 删除 4 条 identifier 用例 - rust-core-api.md 删除命令说明,改写已过时的 macOS/Windows TypeScript 段落
xiaoyumuxi
marked this pull request as ready for review
November 16, 2026 11:25
This was referenced Nov 16, 2026
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
#1856 要求把 Core 里剩下的 5 类语言专属默认值移出 Core。本 PR 只做**第 5 项(行注释符号表)**的 Core 部分。桌面端改动在 1lck/Lithe-IDEA#2036 :它把
PINNED_CORE_REVISION暂时指到本分支的 12d3739,桌面端从自己的语言注册表取注释符号。第 1–4 项(忽略目录、rust-analyzer/gopls 索引排除、go/node 运行时、运行发现)不在本 PR,#1856 保持打开。PR 类型 / Type
editor.lineEdit行为的重构,见下方“复现与根因”)改动说明 / What changes
背景 / Why
editor.lineCommentToken用一张写死的“扩展名 / 语言 ID → 注释符号”表回答“这个文件用什么行注释”。这张表有三个问题:.json,注册表里 JSON 用//。languages[].configuration.lineComment声明的注释符号进不了这张表。插件新增的语言切换注释时,只会收到“没有行注释”。#1856 原本建议 Core 改为从插件清单解析注释符号。本 PR 换了做法:直接删除这个命令,由宿主的语言注册表提供符号。理由是桌面端注册表已经合并了内置语言和插件
languages[]声明,文件到语言的匹配规则(扩展名、文件名、同 ID 覆盖)本来就在那里。再在 Core 里解析一遍插件清单,等于把匹配规则复制一份。删除后,Core 只保留与语言无关的editor.lineEdit变换规则。改动 / Changes
删除
editor.lineCommentTokenrust/crates/editor/src/line_edit.rs:删除LineCommentTokenRequest、LineCommentToken、line_comment_token,以及写死的lookup_line_comment_token表。LineEditRequest.comment_token保持不变:toggleLineComment仍然要求调用方传入符号。rust/crates/editor/src/lib.rs:导出改为只有line_edit和LineEditRequest,crate 文档同步更新。rust/crates/core/src/protocol/command.rs:删除LineCommentToken命令变体和"editor.lineCommentToken"解析分支。rust/crates/core/src/runtime/dispatcher/editor.rs:删除对应的分发分支。测试与 fixture
rust/crates/editor/src/tests.rs:删除 3 个查表测试(常见扩展名与语言 ID、未知扩展名、点文件名)。fixture 测试现在每个用例都按LineEditRequest反序列化。rust/fixtures/editor/line-edit-v1.json:删除 4 个查符号用例,保留 23 个行变换用例,原有格式不变。契约文档
rust/contracts/rust-core-api.md:删除editor.lineCommentToken一行;editor.lineEdit后的说明改为“Core 不知道语言用什么符号,宿主从语言注册表解析commentToken”;“both hosts”改为“hosts”(旧 Windows 客户端已删除)。调用方
只有桌面端
desktop/internal/core/line_edit.go和desktop/internal/workbench/lineedit.go调用这个命令,在上面的桌面端 PR 里一起删除。本 PR 不涉及插件契约(shared/plugins/)、能力版本和插件函数协议,所以不需要登记协议更新记录。不在本 PR 范围内 / Out of scope
类型专属:fix
复现与根因
lineComment。打开.json文件同样提示没有行注释,而语言注册表里 JSON 用//。检查项
TestCommentsForPath在桌面端 PR 里。editor.*命令。.agents/notes/implemented/bug-fix/记录:决策写进了桌面端仓库已有的行操作 Agent Note(2026-11-08-viva-line-edit-core-bridge.md),在桌面端 PR 里重写。范围检查 / Scope checks
插件契约 / Plugin contract
N/A:没有改
shared/plugins/contract/v1/、能力版本或插件函数协议。editor.lineCommentToken是宿主 C ABI 命令,不是插件契约。逻辑归属 / Logic placement
无用代码与重构 / Dead code and refactoring
其他组(功能矩阵、UI、日志、i18n、性能、设置、发行包):N/A,Core 这边没有涉及。功能矩阵条目在桌面端 PR 里更新。
验证 / Verification
cargo fmt --checkcargo test -p lithe-editor -p lithe-corecargo clippy --workspace --all-targets --features lithe-remote/server -- -D warningsbash scripts/rust-core/verify-rust-core-comments.shnode scripts/rust-core/verify-platform-tests.mjsnode scripts/rust-core/affected-crates.mjs--workspace;macOS、Windows:lithe-platform 一组LITHE_CORE_RUST_DIR=<本分支> scripts/desktop/desktop-go.sh test ./internal/core ./internal/editor/syntax ./internal/workbench未能执行的检查和原因: 本地只跑了受影响 crate 的测试和全 workspace 的 clippy,完整
cargo test --workspace由 Draft 的 Linux CI 运行。Windows 没有在本机执行,由 ready 后的 CI 覆盖。提交前确认 / Final checks
main(957a349)创建,目标分支main