From 27f8f8d32cf94d7544e1ff4a0d5ee5f36aa8c2fc Mon Sep 17 00:00:00 2001 From: Yao Jingxi <23722032@bjtu.edu.cn> Date: Mon, 16 Nov 2026 18:10:54 +0800 Subject: [PATCH 1/4] =?UTF-8?q?refactor(desktop):=20=E8=A1=8C=E6=B3=A8?= =?UTF-8?q?=E9=87=8A=E7=AC=A6=E5=8F=B7=E6=94=B9=E7=94=B1=E8=AF=AD=E8=A8=80?= =?UTF-8?q?=E6=B3=A8=E5=86=8C=E8=A1=A8=E6=8F=90=E4=BE=9B=EF=BC=8CCore=20?= =?UTF-8?q?=E5=9B=BA=E5=AE=9A=E5=88=B0=2012d3739=20(#1856)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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,更新功能矩阵说明与证据。 --- .../2026-11-08-viva-line-edit-core-bridge.md | 29 +++++++----- desktop/internal/core/line_edit.go | 12 ----- desktop/internal/core/line_edit_test.go | 31 ------------- desktop/internal/editor/syntax/language.go | 21 +++++++++ .../internal/editor/syntax/language_test.go | 44 +++++++++++++++++++ desktop/internal/editor/syntax/languages.go | 7 ++- desktop/internal/workbench/lineedit.go | 41 +++++++++-------- scripts/desktop/build-desktop-core.sh | 8 +++- .../features/editor-line-operations.json | 10 +++-- 9 files changed, 122 insertions(+), 81 deletions(-) diff --git a/.agents/notes/implemented/architecture/2026-11-08-viva-line-edit-core-bridge.md b/.agents/notes/implemented/architecture/2026-11-08-viva-line-edit-core-bridge.md index 778654c6e9..6d807b8d70 100644 --- a/.agents/notes/implemented/architecture/2026-11-08-viva-line-edit-core-bridge.md +++ b/.agents/notes/implemented/architecture/2026-11-08-viva-line-edit-core-bridge.md @@ -4,37 +4,46 @@ ## 先说结论 -Viva 的 Core 适配层可以取得语言的行注释符号,并调用共享的注释、复制、删除和移动行规则。适配层不修改文档;快捷键、菜单、撤销和窗口接线还未完成,不能将接口可调用当作用户功能已实现。 +切换行注释、复制、删除、移动行的变换规则只在 Core 的 `editor.lineEdit`;Core 不认识任何语言,行注释符号由桌面端语言注册表给出。桌面端只取选中行及前后各一行交给 Core,在后台调用,结果核对文档版本后作为一次可撤销编辑写回。 ## 问题 -行变换需要正确处理跨行选区、UTF-16 代理对、CRLF 和无操作边界。Go 中再实现这些规则会与 Core 和其他宿主分叉;但 Core 需要完整文本,如果直接在键盘事件中同步传入大文档,会阻塞交互并造成额外复制。 +行变换需要正确处理跨行选区、UTF-16 代理对、CRLF 和无操作边界,Go 中再实现一遍会与 Core 分叉。注释符号是语言知识:Core 曾用一张写死的扩展名表回答 `editor.lineCommentToken`,与编辑器语言注册表重复,插件声明的语言也进不了那张表,违反 Core 对语言零特判的约束([#1856](https://github.com/1lck/Lithe-IDEA/issues/1856) 第 5 项)。Core 需要文本,在键盘事件里同步传入整份大文档会阻塞输入。 ## 决策 -行变换和注释符号由 `editor.lineEdit` 与 `editor.lineCommentToken` 决定。返回的替换范围和选区使用 UTF-16 偏移;`applied: false` 是无操作,不能改写文档或消费快捷键。未来接线必须核对文档身份、版本、选区和输入法组合状态,将已确认的变更作为一个可撤销编辑;迟到结果不能覆盖新内容。 +- 变换规则:`editor.lineEdit` 返回 UTF-16 偏移的替换范围和选区;`applied: false` 是无操作,不改写文档。`toggleLineComment` 必须带 `commentToken`。 +- 注释符号:`syntax.Registry.CommentsForPath` 是唯一来源。内置语言在 `desktop/internal/editor/syntax/languages.go` 声明 `Comments`;插件语言用 `languages[].configuration.lineComment` 声明,替换同 ID 内置语言时未声明的字段沿用内置值;只为服务器或调试器认领文件、既无语法也无注释的插件语言(如调试插件的 `clangd`)沿用按文件名选出的内置语言的注释,与 `SyntaxForPath` 沿用其配色一致。没有行注释符号时提示 `desktop.editor.noLineComment`,不调用 Core。 +- 有界输入:`editorview.View.LineEditInput` 只取选中行及前后各一行,超过 1 MiB 不处理;输入法组合中或只读视图不处理。 +- 接线:快捷键(Alt+上下、Alt+Shift+上下、Primary+Shift+K、Primary+/)和编辑器右键菜单都走 `workbench.runLineOperation`;Core 在后台调用,`ApplyLineEdit` 在文档版本变化后丢弃迟到结果。 -完整文本同步调用的成本和局部范围方案跟踪 [#1805](https://github.com/1lck/Lithe-IDEA/issues/1805)。Core 规则未支持安全的有界输入前,不把完整文档调用直接放入 UI 线程,也不在 Go 复制无操作或行选择规则来规避约束。 +整份文档复制的剩余成本跟踪 [#1805](https://github.com/1lck/Lithe-IDEA/issues/1805)。 ## 考虑过的备选方案 -- 各平台独立计算注释和行范围:会产生不同的空行、行尾和选区行为,故复用 Core。 -- 整份文档同步调用 Core:小文件简单,但大文件的序列化和处理会阻塞输入;先处理性能与快捷键归属。 -- 异步计算后无条件消费快捷键:无操作结果不能及时交给其他处理器,违反 Core 契约;需要先设计无损的接线方式。 +- 各平台独立计算注释和行范围:空行、行尾和选区行为会分叉,故复用 Core。 +- Core 保留注释符号表:与语言注册表是两份来源,插件新增语言时还要改 Core,违反 Core 零语言特判;已于 #1856 删除 `editor.lineCommentToken`。 +- 整份文档同步调用 Core:大文件的序列化和处理会阻塞输入,改为局部窗口加后台调用。 ## 后果 -共享样例可验证桥接结果,但用户仍不能通过 Viva 执行这些命令。局部处理、界面接线、平台快捷键、组合输入、撤销与真实窗口性能验收均未完成。接口只处理内存快照,不创建资源或写入发行包。 +新增语言只需在内置表或插件清单里声明注释,Core 和行操作代码不用改。`.json` 按内置语言表使用 `//`(与 VS Code 一致),不再提示没有行注释。接口只处理内存快照,不创建资源或写入发行包。 ## 验证 -- `scripts/desktop/desktop-go.sh test -race ./internal/core -run 'Test(LineEditsUseCoreFixtures|LineCommentTokenUsesCoreLanguageTable)' -count=3 -timeout=90s`:macOS 验证共享行变换 fixture、语言符号和未知语言。 +- `scripts/desktop/desktop-go.sh test ./internal/editor/syntax -run '^TestCommentsForPath$' -count=1 -timeout=60s`:旧 Core 表覆盖的扩展名全部保留符号;插件声明覆盖、同 ID 继承、无语法插件语言回退、自带语法的插件语言不回退。 +- `scripts/desktop/desktop-go.sh test ./internal/core -run '^TestLineEditsUseCoreFixtures$' -count=1 -timeout=90s`:共享行变换 fixture。 +- `scripts/desktop/desktop-go.sh test ./internal/workbench -run '^Test(LineOperationKeys|LineOperationsThroughCore|EditorContextMenuRunsLineOperation)$' -count=1 -timeout=120s`:快捷键映射、经 Core 的注释切换与右键菜单。 - `scripts/desktop/desktop-go.sh test ./internal/core -run '^$' -bench '^BenchmarkCoreToggleLineComment$' -benchtime=3x -count=1 -timeout=90s`:Apple M4 上合成 100 KiB、1 MiB 和 8 MiB 文档的平均调用约为 5.37、31.2 和 248.6 ms;8 MiB 的 Go 分配约 29.5 MiB,不包含 Rust 分配或峰值。该单机基准不代表真实窗口或 Windows 性能。 ## 适用范围 - `desktop/internal/core/line_edit.go` - `desktop/internal/core/line_edit_test.go` +- `desktop/internal/editorview/lineedit.go` +- `desktop/internal/workbench/lineedit.go` +- `desktop/internal/workbench/editor_menu.go` +- `desktop/internal/editor/syntax/language.go` +- `desktop/internal/editor/syntax/languages.go` - `https://github.com/Lithe-IDEA/Lithe-core-rust/blob/main/rust/fixtures/editor/line-edit-v1.json` - `shared/platform-feature-matrix/features/editor-line-operations.json` -- [固定 Core 的行变换实现](https://github.com/Lithe-IDEA/Lithe-core-rust/blob/0ffd327b4329261e393b08ed76fbd134b4dd17e9/rust/lithe-core/src/editor/line_edit.rs) diff --git a/desktop/internal/core/line_edit.go b/desktop/internal/core/line_edit.go index df3c2f45d8..015188ae28 100644 --- a/desktop/internal/core/line_edit.go +++ b/desktop/internal/core/line_edit.go @@ -35,18 +35,6 @@ type LineEditOutcome struct { SelectionLength int `json:"selectionLength"` } -// LineCommentToken returns Core's language token or nil when none is known. -// The identifier may be a filename, extension or language ID. -func (c *Client) LineCommentToken(ctx context.Context, identifier string) (*string, error) { - var response struct { - Token *string `json:"token"` - } - err := c.Execute(ctx, "editor.lineCommentToken", struct { - Identifier string `json:"identifier"` - }{Identifier: identifier}, &response) - return response.Token, err -} - // LineEdit asks Core for a pure transformation. It does not write the file or // change the live editor; the caller must check the captured document version // and selection before applying the answer as one undoable edit. diff --git a/desktop/internal/core/line_edit_test.go b/desktop/internal/core/line_edit_test.go index 7e02b9f5c9..abb578bae8 100644 --- a/desktop/internal/core/line_edit_test.go +++ b/desktop/internal/core/line_edit_test.go @@ -29,25 +29,6 @@ func TestLineEditsUseCoreFixtures(t *testing.T) { client := NewClient() for _, item := range fixture.Cases { t.Run(item.Name, func(t *testing.T) { - var kind struct { - Identifier *string `json:"identifier"` - } - if err := json.Unmarshal(item.Request, &kind); err != nil { - t.Fatal(err) - } - if kind.Identifier != nil { - var expected struct { - Token *string `json:"token"` - } - if err := json.Unmarshal(item.Expected, &expected); err != nil { - t.Fatal(err) - } - result, err := client.LineCommentToken(testContext(t), *kind.Identifier) - if err != nil || !reflect.DeepEqual(result, expected.Token) { - t.Fatalf("token = %v, error = %v; want %v", result, err, expected.Token) - } - return - } var request LineEditRequest var expected LineEditOutcome if err := json.Unmarshal(item.Request, &request); err != nil { @@ -64,18 +45,6 @@ func TestLineEditsUseCoreFixtures(t *testing.T) { } } -func TestLineCommentTokenUsesCoreLanguageTable(t *testing.T) { - client, ctx := NewClient(), testContext(t) - token, err := client.LineCommentToken(ctx, "example.go") - if err != nil || token == nil || *token != "//" { - t.Fatalf("Go token = %v, error = %v", token, err) - } - token, err = client.LineCommentToken(ctx, "unknown.fixture-extension") - if err != nil || token != nil { - t.Fatalf("unknown token = %v, error = %v", token, err) - } -} - func BenchmarkCoreToggleLineComment(b *testing.B) { for _, size := range []struct { name string diff --git a/desktop/internal/editor/syntax/language.go b/desktop/internal/editor/syntax/language.go index 0b040b056d..9624d3ec04 100644 --- a/desktop/internal/editor/syntax/language.go +++ b/desktop/internal/editor/syntax/language.go @@ -295,6 +295,27 @@ func (r *Registry) SyntaxForPath(path string) *Syntax { return nil } +// CommentsForPath returns the comment delimiters of a file by its name: those of the language +// ForPath gives the file, zero when no language takes it. The registry is the only source of +// comment delimiters; a plugin declares its language's through configuration.lineComment and +// blockComment. +// +// A plugin language that names files for its servers and debuggers and brings neither a +// grammar nor comments of its own keeps the comments of the bundled language its name +// selects, as SyntaxForPath keeps that language's colors. +func (r *Registry) CommentsForPath(path string) Comments { + language, ok := r.ForPath(path) + if !ok { + return Comments{} + } + if language.Comments == (Comments{}) && language.Scope == "" { + if bundled := bundledForName(fileName(path)); bundled != nil { + return bundled.Comments + } + } + return language.Comments +} + // fileName returns the lowercased last element of a path with "/" or "\" as separators. func fileName(path string) string { return strings.ToLower(path[strings.LastIndexAny(path, `/\`)+1:]) diff --git a/desktop/internal/editor/syntax/language_test.go b/desktop/internal/editor/syntax/language_test.go index 596c19e68b..0b2edd2645 100644 --- a/desktop/internal/editor/syntax/language_test.go +++ b/desktop/internal/editor/syntax/language_test.go @@ -394,3 +394,47 @@ func TestPluginLanguageWithoutGrammarKeepsBundledColors(t *testing.T) { t.Fatalf("SyntaxForPath of an empty path = %v", s) } } + +func TestCommentsForPath(t *testing.T) { + r := NewRegistry() + // Every file the line comment toggle took while Core kept its own table keeps its token. + for token, names := range map[string][]string{ + "//": {"a.c", "a.h", "a.cpp", "a.cc", "a.cxx", "a.hpp", "a.hxx", "a.kt", "build.kts", "a.swift", "a.js", + "a.jsx", "a.mjs", "a.cjs", "a.ts", "a.tsx", "main.go", "lib.rs", "a.cs", "a.php", "a.dart", "a.scala", + "a.groovy", "a.m", "a.mm", "a.zig"}, + "#": {"a.py", "a.rb", "a.sh", "a.bash", "a.zsh", "a.yml", "a.yaml", "Cargo.toml", "a.ini", "setup.cfg", + "nginx.conf", "app.properties", ".env", "prod.env", "a.r", "a.rmd", "a.pl", "a.ex"}, + "--": {"a.sql", "a.lua", "Main.hs"}, + } { + for _, name := range names { + if got := r.CommentsForPath("src/" + name).Line; got != token { + t.Errorf("CommentsForPath(%q).Line = %q, want %q", name, got, token) + } + } + } + // A language with block comments only, or a file no language takes, has no line token. + for _, path := range []string{"README.md", "site.css", "unknown.zzz", ""} { + if got := r.CommentsForPath(path).Line; got != "" { + t.Errorf("CommentsForPath(%q).Line = %q, want none", path, got) + } + } + + own := strings.Replace(demoGrammar, "source.demo", "source.own", 1) + if failed, _ := r.SetPluginLanguages([]PluginLanguage{ + // A plugin declares its language's comments. + {ID: "demo", Extensions: []string{"demo"}, Grammar: []byte(demoGrammar), Comments: Comments{Line: ";;"}}, + // A plugin language for a bundled one inherits the comments it does not set. + {ID: "go", Extensions: []string{"go"}}, + // A plugin language that only names files keeps the bundled language's comments. + {ID: "clangd", Extensions: []string{"c", "lua"}}, + // A plugin language with a grammar of its own has only the comments it declares. + {ID: "own", Extensions: []string{"py"}, Grammar: []byte(own)}, + }); len(failed) != 0 { + t.Fatalf("failed %v", failed) + } + for path, want := range map[string]string{"a.demo": ";;", "main.go": "//", "main.c": "//", "init.lua": "--", "a.py": ""} { + if got := r.CommentsForPath(path).Line; got != want { + t.Errorf("with plugins, CommentsForPath(%q).Line = %q, want %q", path, got, want) + } + } +} diff --git a/desktop/internal/editor/syntax/languages.go b/desktop/internal/editor/syntax/languages.go index 09c931bebe..65e9a095c4 100644 --- a/desktop/internal/editor/syntax/languages.go +++ b/desktop/internal/editor/syntax/languages.go @@ -301,7 +301,7 @@ var bundledLanguages = []Language{ {ID: "shell", Extensions: []string{".sh", ".bash", ".zsh"}, FileNames: []string{".bashrc", ".zshrc", ".bash_profile", ".zprofile", ".profile"}, Comments: hashComments, Brackets: cBrackets, AutoClosing: cAutoClosing}, - {ID: "dotenv", Scope: "source.dotenv", Rules: DotenvRules, FileNames: []string{".env"}, FilePrefixes: []string{".env."}, + {ID: "dotenv", Scope: "source.dotenv", Rules: DotenvRules, Extensions: []string{".env"}, FileNames: []string{".env"}, FilePrefixes: []string{".env."}, Comments: hashComments, Brackets: cBrackets, AutoClosing: cAutoClosing}, {ID: "dockerfile", Extensions: []string{".dockerfile"}, FileNames: []string{"dockerfile", "containerfile"}, FilePrefixes: []string{"dockerfile.", "containerfile."}, @@ -316,11 +316,12 @@ var bundledLanguages = []Language{ {ID: "go", Scope: "source.go", Rules: CodeRules, Extensions: []string{".go"}, Comments: cComments, Brackets: cBrackets, AutoClosing: scriptClosing}, {ID: "graphql", Extensions: []string{".graphql", ".gql"}, Comments: hashComments, Brackets: cBrackets, AutoClosing: cAutoClosing}, + {ID: "haskell", Extensions: []string{".hs"}, Comments: Comments{Line: "--", Block: Pair{"{-", "-}"}}, Brackets: cBrackets, AutoClosing: cAutoClosing}, {ID: "hcl", Extensions: []string{".tf", ".tfvars", ".hcl"}, Comments: Comments{Line: "#", Block: Pair{"/*", "*/"}}, Brackets: cBrackets, AutoClosing: cAutoClosing}, {ID: "html", Scope: "text.html.basic", Rules: HTMLRules, Extensions: []string{".html", ".htm", ".shtml", ".xhtml", ".mdoc", ".jsp", ".asp", ".aspx", ".jshtm"}, Comments: markupBlock, Brackets: markupBrackets, AutoClosing: markupClosing}, - {ID: "ini", Scope: "source.ini", Rules: INIRules, Extensions: []string{".ini", ".properties", ".gitconfig"}, + {ID: "ini", Scope: "source.ini", Rules: INIRules, Extensions: []string{".ini", ".properties", ".cfg", ".conf", ".gitconfig"}, FileNames: []string{".gitconfig", ".editorconfig"}, Comments: hashComments, Brackets: cBrackets, AutoClosing: cAutoClosing}, {ID: "javascript", Scope: "source.js", Rules: ScriptRules, Extensions: []string{".js", ".es6", ".mjs", ".cjs"}, FileNames: []string{"jakefile"}, Comments: cComments, Brackets: cBrackets, AutoClosing: scriptClosing}, @@ -339,6 +340,8 @@ var bundledLanguages = []Language{ {ID: "markdown", Scope: "text.html.markdown", Rules: MarkdownRules, Extensions: []string{".md", ".markdown", ".mdown", ".mkdn", ".mkd", ".mdwn", ".mdtxt", ".mdtext"}, Comments: markupBlock, Brackets: cBrackets, AutoClosing: []Pair{{"{", "}"}, {"[", "]"}, {"(", ")"}, {"<", ">"}}}, {ID: "objective-c", Extensions: []string{".m"}, Comments: cComments, Brackets: cBrackets, AutoClosing: cAutoClosing}, + {ID: "objective-cpp", Extensions: []string{".mm"}, Comments: cComments, Brackets: cBrackets, AutoClosing: cAutoClosing}, + {ID: "perl", Extensions: []string{".pl", ".pm"}, Comments: hashComments, Brackets: cBrackets, AutoClosing: cAutoClosing}, {ID: "php", Extensions: []string{".php", ".php4", ".php5", ".phtml", ".ctp"}, Comments: cComments, Brackets: cBrackets, AutoClosing: cAutoClosing}, {ID: "proto", Extensions: []string{".proto"}, Comments: cComments, Brackets: cBrackets, AutoClosing: cAutoClosing}, {ID: "python", Extensions: []string{".py", ".rpy", ".pyw", ".cpy", ".gyp", ".gypi"}, diff --git a/desktop/internal/workbench/lineedit.go b/desktop/internal/workbench/lineedit.go index 8fcca9619e..e2c8c7e151 100644 --- a/desktop/internal/workbench/lineedit.go +++ b/desktop/internal/workbench/lineedit.go @@ -12,18 +12,19 @@ import ( // Line operations: toggle comment, delete, move and copy lines. // -// Core owns every rule (what a comment is for a language, how a selection that ends at the -// start of a line is treated, CRLF, UTF-16 offsets). This file only takes the lines an -// operation can touch from the editor, asks Core off the window thread and puts the answer -// back as one undoable edit while the document is still at the revision the window was -// taken at. A no-op answer (moving the first line up) leaves the document alone. +// Core owns every rule of the edit (how a selection that ends at the start of a line is +// treated, CRLF, UTF-16 offsets) and knows no language: the comment token comes from the +// editor's language registry, where each bundled or plugin language declares its comments. +// This file only takes the lines an operation can touch from the editor, asks Core off the +// window thread and puts the answer back as one undoable edit while the document is still at +// the revision the window was taken at. A no-op answer (moving the first line up) leaves the +// document alone. // editorKernel is what the editor features of this package need beyond the common Kernel. The // application's kernel (core.Client) has all of it; keeping the list here keeps the editor // features out of the shared interface. type editorKernel interface { LineEdit(context.Context, core.LineEditRequest) (core.LineEditOutcome, error) - LineCommentToken(context.Context, string) (*string, error) DecodeFileBytes(context.Context, []byte, string) (core.DecodedFile, error) EncodeFileText(context.Context, string, string, *bool) (core.EncodedText, error) ReduceNavigationHistory(context.Context, core.NavigationHistory, core.NavigationHistoryEvent) (core.NavigationHistory, *core.NavigationLocation, error) @@ -104,22 +105,20 @@ func (a *App) runLineOperation(p *project, d *document, op core.LineEditOperatio return } a.performed("editor.lineEdit."+string(op), surfaceShortcut) - documentID, name := d.id, d.name - a.background(p, kernelCallTimeout, func(ctx context.Context) func(*App) { - request := core.LineEditRequest{ - Operation: op, Source: in.Source, - SelectionStart: in.SelectionStart, SelectionLength: in.SelectionLength, - } - if op == core.ToggleLineComment { - token, err := kernel.LineCommentToken(ctx, name) - if err != nil { - return func(a *App) { a.lineEditFailed(err) } - } - if token == nil { - return func(a *App) { a.notifyInfo(i18n.Shared(a.language(), "desktop.editor.noLineComment")) } - } - request.CommentToken = token + request := core.LineEditRequest{ + Operation: op, Source: in.Source, + SelectionStart: in.SelectionStart, SelectionLength: in.SelectionLength, + } + if op == core.ToggleLineComment { + token := a.syntaxRegistry().CommentsForPath(d.path).Line + if token == "" { + a.notifyInfo(i18n.Shared(a.language(), "desktop.editor.noLineComment")) + return } + request.CommentToken = &token + } + documentID := d.id + a.background(p, kernelCallTimeout, func(ctx context.Context) func(*App) { outcome, err := kernel.LineEdit(ctx, request) return func(a *App) { if err != nil { diff --git a/scripts/desktop/build-desktop-core.sh b/scripts/desktop/build-desktop-core.sh index b94852e8e0..83ee9ee685 100755 --- a/scripts/desktop/build-desktop-core.sh +++ b/scripts/desktop/build-desktop-core.sh @@ -27,7 +27,11 @@ native_path() { fi } -# Lithe-core-rust main at 957a349, #64 squash-merged: gitExecution.consoleQueries names the query +# Lithe-core-rust refactor/1856-line-comment-table at 12d3739, on top of main 957a349: +# editor.lineCommentToken and Core's table of comment tokens are gone; the desktop takes the +# token from its language registry and editor.lineEdit is unchanged (#1856). Replace it with the +# squash-merge commit on main once the Core PR is merged. +# Main at 957a349 is #64 squash-merged: gitExecution.consoleQueries names the query # categories the Git console records and queryCategory names a read the command does not tell # apart; git.consolePresentation takes display options, all false by default as in IDEA; output # folds only past ten lines and a deletion never folds; a failed unrecorded query still reports its @@ -135,7 +139,7 @@ PINNED_CORE_REPOSITORY="https://github.com/Lithe-IDEA/Lithe-core-rust.git" # the contract, plugin guides, reference and SDKs live only in shared/plugins; on top of #16 (reported Git queries folded in the console), # #15 (git.write cherryPick, revert and reset fields), #14 (word-level changed ranges of diff # rows), #13, #8, #7, #6 and #4. -PINNED_CORE_REVISION="957a349a5d8b571d416925c8231509572c2053f5" +PINNED_CORE_REVISION="12d3739b05f8854ff9bfa5dcd33cc1b6d62e7eb2" PROFILE="debug" while [[ $# -gt 0 ]]; do case "$1" in diff --git a/shared/platform-feature-matrix/features/editor-line-operations.json b/shared/platform-feature-matrix/features/editor-line-operations.json index 3faea514a2..da2691b059 100644 --- a/shared/platform-feature-matrix/features/editor-line-operations.json +++ b/shared/platform-feature-matrix/features/editor-line-operations.json @@ -11,7 +11,9 @@ "desktop/internal/editorview/lineedit.go", "desktop/internal/editorview/lineedit_test.go", "desktop/internal/workbench/lineedit.go", - "desktop/internal/workbench/lineedit_test.go" + "desktop/internal/workbench/lineedit_test.go", + "desktop/internal/editor/syntax/language.go", + "desktop/internal/editor/syntax/language_test.go" ] }, "windows": { @@ -22,11 +24,13 @@ "desktop/internal/editorview/lineedit.go", "desktop/internal/editorview/lineedit_test.go", "desktop/internal/workbench/lineedit.go", - "desktop/internal/workbench/lineedit_test.go" + "desktop/internal/workbench/lineedit_test.go", + "desktop/internal/editor/syntax/language.go", + "desktop/internal/editor/syntax/language_test.go" ] }, "owner": "Editor", - "notes": "Viva:Alt+上下移动行,Alt+Shift+上下复制行,Primary+Shift+K 删除行,Primary+/ 切换行注释,右键菜单同样提供;只把选中行及前后各一行交给 Core editor.lineEdit(后台调用,结果按文档 revision 校验后作为一次可撤销编辑应用,过期结果丢弃),注释符号由 editor.lineCommentToken 决定。多行选区、CRLF 与非 BMP 的行为由 Core fixture 保证;整机输入法组合与大文件输入延迟的实机验收仍待完成。", + "notes": "Viva:Alt+上下移动行,Alt+Shift+上下复制行,Primary+Shift+K 删除行,Primary+/ 切换行注释,右键菜单同样提供;只把选中行及前后各一行交给 Core editor.lineEdit(后台调用,结果按文档 revision 校验后作为一次可撤销编辑应用,过期结果丢弃),注释符号取自编辑器语言注册表(内置语言与插件 languages[].configuration.lineComment),Core 不含语言表。多行选区、CRLF 与非 BMP 的行为由 Core fixture 保证;整机输入法组合与大文件输入延迟的实机验收仍待完成。", "verification": "两端分别验证单行、多行、空行、选区结束在行首、CRLF、非 BMP 字符、撤销重做、输入法组合和无操作时快捷键归属;覆盖请求期间编辑或关闭文件、过期结果不覆盖新内容,以及小文件和大文件的输入延迟与内存。Core fixture 不替代实际编辑器及平台验收。", "legacy": { "revision": "5a54c41aa37a4e6e6b68918a4b05765b9dd07a36", From da1b08b3bd4aecaf275e6e003da60884f0bfa7c5 Mon Sep 17 00:00:00 2001 From: Yao Jingxi <23722032@bjtu.edu.cn> Date: Mon, 16 Nov 2026 18:15:55 +0800 Subject: [PATCH 2/4] =?UTF-8?q?fix(desktop):=20=E6=8C=89=E6=96=87=E6=A1=A3?= =?UTF-8?q?=E5=90=8D=E5=8F=96=E8=A1=8C=E6=B3=A8=E9=87=8A=E7=AC=A6=E5=8F=B7?= =?UTF-8?q?=EF=BC=8C=E4=B8=8E=E6=89=93=E5=BC=80=E6=96=87=E6=A1=A3=E6=97=B6?= =?UTF-8?q?=E9=80=89=E8=AF=AD=E8=A8=80=E7=9A=84=E4=BE=9D=E6=8D=AE=E4=B8=80?= =?UTF-8?q?=E8=87=B4=20(#1856)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 插件内容文档的 path 是 URI,文件名只在 name 里;打开文档时 ForPath 也按 name 选语言。 --- desktop/internal/workbench/lineedit.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/desktop/internal/workbench/lineedit.go b/desktop/internal/workbench/lineedit.go index e2c8c7e151..411f3f112f 100644 --- a/desktop/internal/workbench/lineedit.go +++ b/desktop/internal/workbench/lineedit.go @@ -110,7 +110,9 @@ func (a *App) runLineOperation(p *project, d *document, op core.LineEditOperatio SelectionStart: in.SelectionStart, SelectionLength: in.SelectionLength, } if op == core.ToggleLineComment { - token := a.syntaxRegistry().CommentsForPath(d.path).Line + // By the name, as the document's language was chosen when it opened: a plugin's content + // document has a URI for a path and its file name only in the name. + token := a.syntaxRegistry().CommentsForPath(d.name).Line if token == "" { a.notifyInfo(i18n.Shared(a.language(), "desktop.editor.noLineComment")) return From 12ef04bcec809d554957dbbba7be154bf502f9ce Mon Sep 17 00:00:00 2001 From: Yao Jingxi <23722032@bjtu.edu.cn> Date: Mon, 16 Nov 2026 18:17:06 +0800 Subject: [PATCH 3/4] =?UTF-8?q?fix(desktop):=20Haskell=20=E4=B8=8D?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E9=85=8D=E5=AF=B9=E5=8D=95=E5=BC=95=E5=8F=B7?= =?UTF-8?q?=20(#1856)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Haskell 名字里的 ' 表示撇号(如 foldl'),不是字符串定界符。 --- desktop/internal/editor/syntax/languages.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/desktop/internal/editor/syntax/languages.go b/desktop/internal/editor/syntax/languages.go index 65e9a095c4..336ef6083f 100644 --- a/desktop/internal/editor/syntax/languages.go +++ b/desktop/internal/editor/syntax/languages.go @@ -316,7 +316,9 @@ var bundledLanguages = []Language{ {ID: "go", Scope: "source.go", Rules: CodeRules, Extensions: []string{".go"}, Comments: cComments, Brackets: cBrackets, AutoClosing: scriptClosing}, {ID: "graphql", Extensions: []string{".graphql", ".gql"}, Comments: hashComments, Brackets: cBrackets, AutoClosing: cAutoClosing}, - {ID: "haskell", Extensions: []string{".hs"}, Comments: Comments{Line: "--", Block: Pair{"{-", "-}"}}, Brackets: cBrackets, AutoClosing: cAutoClosing}, + // ' is not paired: it marks primes in names, as foldl'. + {ID: "haskell", Extensions: []string{".hs"}, Comments: Comments{Line: "--", Block: Pair{"{-", "-}"}}, Brackets: cBrackets, + AutoClosing: []Pair{{"{", "}"}, {"[", "]"}, {"(", ")"}, {`"`, `"`}}}, {ID: "hcl", Extensions: []string{".tf", ".tfvars", ".hcl"}, Comments: Comments{Line: "#", Block: Pair{"/*", "*/"}}, Brackets: cBrackets, AutoClosing: cAutoClosing}, {ID: "html", Scope: "text.html.basic", Rules: HTMLRules, Extensions: []string{".html", ".htm", ".shtml", ".xhtml", ".mdoc", ".jsp", ".asp", ".aspx", ".jshtm"}, From c9cfd753a52663051410c3d79fe0ff9e1be1b9b1 Mon Sep 17 00:00:00 2001 From: Yao Jingxi <23722032@bjtu.edu.cn> Date: Mon, 16 Nov 2026 19:49:15 +0800 Subject: [PATCH 4/4] =?UTF-8?q?chore(desktop):=20Core=20=E5=9B=BA=E5=AE=9A?= =?UTF-8?q?=E5=88=B0=20main=205a8d786=EF=BC=8C#66=20=E5=90=88=E5=85=A5?= =?UTF-8?q?=E5=90=8E=E6=8D=A2=E6=8E=89=E5=88=86=E6=94=AF=20commit=20(#1856?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/desktop/build-desktop-core.sh | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/scripts/desktop/build-desktop-core.sh b/scripts/desktop/build-desktop-core.sh index 1af0effabc..13f6d59ccb 100755 --- a/scripts/desktop/build-desktop-core.sh +++ b/scripts/desktop/build-desktop-core.sh @@ -27,17 +27,20 @@ native_path() { fi } -# Lithe-core-rust refactor/1856-line-comment-table at 12d3739, on top of main 957a349: -# editor.lineCommentToken and Core's table of comment tokens are gone; the desktop takes the -# token from its language registry and editor.lineEdit is unchanged (#1856). Replace it with the -# squash-merge commit on main once the Core PR is merged. -# Main at 957a349 is #64 squash-merged: gitExecution.consoleQueries names the query -# categories the Git console records and queryCategory names a read the command does not tell -# apart; git.consolePresentation takes display options, all false by default as in IDEA; output -# folds only past ten lines and a deletion never folds; a failed unrecorded query still reports its -# command, stderr and exit; a reported query's started event carries its queryCategory (#2025). It -# is on top of #65, squash-merged into main as db54ba0: every workspace.repositories entry has an -# id relative to the opened folder, a display name and a role (workspace or nested); +# Lithe-core-rust main at 5a8d786, #67 squash-merged: toolchain candidates list the installations +# JAVA_HOME and PATH point at. It is on top of #68, squash-merged into main: Core no longer +# recognizes rust-analyzer or gopls; a language server declares indexingExclusions, and the launch +# plan's sessionPolicy, which the desktop sends to lsp.startServer unchanged, carries it. It is on +# top of #66, squash-merged into main: editor.lineCommentToken and Core's table of comment tokens +# are gone; the desktop takes the token from its language registry and editor.lineEdit is +# unchanged (#1856). It is on top of #64, squash-merged into main: gitExecution.consoleQueries +# names the query categories the Git console records and queryCategory names a read the command +# does not tell apart; git.consolePresentation takes display options, all false by default as in +# IDEA; output folds only past ten lines and a deletion never folds; a failed unrecorded query +# still reports its command, stderr and exit; a reported query's started event carries its +# queryCategory (#2025). It is on top of #65, squash-merged into main as db54ba0: every +# workspace.repositories entry has an id relative to the opened folder, a display name and a role +# (workspace or nested); # git.workspaceRepositorySelection keeps the repository a view picked while discovery still lists # it and otherwise falls back to the workspace repository, then the first one; # git.workspaceChangeGroups groups status changes per repository with their staged counts, the @@ -145,7 +148,7 @@ PINNED_CORE_REPOSITORY="https://github.com/Lithe-IDEA/Lithe-core-rust.git" # the contract, plugin guides, reference and SDKs live only in shared/plugins; on top of #16 (reported Git queries folded in the console), # #15 (git.write cherryPick, revert and reset fields), #14 (word-level changed ranges of diff # rows), #13, #8, #7, #6 and #4. -PINNED_CORE_REVISION="12d3739b05f8854ff9bfa5dcd33cc1b6d62e7eb2" +PINNED_CORE_REVISION="5a8d786e9b44a5a8c7a977a8b376264fa941dcd9" PROFILE="debug" while [[ $# -gt 0 ]]; do case "$1" in