完成待办清单全部 6 项(T1-T6)
T1 移动包同步(internal/app/movepkg.go + renameentry.go)
gopls 不声明 willRename,改用 go/parser 精确定位 ImportSpec.Path,
目录移动改全仓 import 路径、单文件跨目录移动改 package 声明。
写盘失败整体恢复并回滚 rename;已打开且无改动的缓冲区用 Reset 同步。
集成测试在临时 Go 模块里移目录后直接跑 go build ./... 通过。
T2 输出/问题面板右键(panel_menu.go + output.go + popmenu.go)
新增 openPopAt 让菜单贴指针弹出;复制选中行/复制全部/清空输出。
真窗口截图确认位置正确、无裁切。
**范围缩窄**:终端从 mygo v0.7.4 起就自带原生 ContextMenu,原判断是误报。
T3 snippet 补全(completion_snippet.go + lsp/protocol.go)
snippetSupport 改 true;实测 gopls v0.23 返回 insertTextFormat=2、
textEdit.newText="Print(${1:})",接上 mygo v0.9.0 的 ParseSnippet。
解析失败降级成纯文本(支持嵌套占位/choices 剥离),结果按模板缓存。
端到端 Tester 验证接受补全后得到 fmt.Print() 且光标停在括号内。
T4 本地历史超限可见(history.go)
静默 return 改为返回 histSkipped,输出面板提示;每文件整个会话只提一次。
T5 全局搜索并发(palette.go)
NumCPU(上限 8)个 worker 并发读盘,结果按文件序合并保证顺序稳定;
命中上限停止派发;512KB 以上被跳过的文件数显示成面板底部提示。
T6 清理根目录残留;4 个 0 字节 .sock 被环境安全守卫拦住未删(已 gitignore)。
验证:gofmt 空、build/vet OK、go test -count=1 ./... 全绿(282 个测试)、
新增并发/剪贴板/回滚用例 go test -race 无数据竞争。
docs/MyGoland-待办与规划.md 已清空待办,只剩 6 项规划与完成索引。
This commit is contained in:
1 parent
d9db634066
commit
e408300324
21 files changed
+1515
-200
No files matched your search
@@ -0,0 +1,65 @@
|
||||
package lsp
|
||||
|
||||
import (
|
||||
"context"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
// TestGoplsCompletionSnippetFormat 固化 2026-11-12 的实测结论。
|
||||
//
|
||||
// 声明 snippetSupport=true 之后,gopls v0.23 对函数补全返回:
|
||||
//
|
||||
// insertTextFormat = 2
|
||||
// insertText = "" (空)
|
||||
// textEdit.newText = "Print(${1:})"
|
||||
//
|
||||
// 也就是说插入内容只在 textEdit 里,且占位符是「空默认值」的 ${1:}。
|
||||
// 早期把 insertTextFormat 当成可选项、只看 insertText 的实现会漏掉这类补全。
|
||||
// gopls 换行为时这条会红,正好提醒重新核对接线。
|
||||
func TestGoplsCompletionSnippetFormat(t *testing.T) {
|
||||
c, dir, _ := startTestClient(t)
|
||||
src := "package main\n\nimport \"fmt\"\n\nfunc main() {\n\tfmt.Pr\n}\n"
|
||||
path := filepath.Join(dir, "main.go")
|
||||
writeFile(t, path, src)
|
||||
|
||||
uri := PathToURI(path)
|
||||
if err := c.DidOpen(uri, "go", 1, src); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
pos := OffsetToPosition(src, len(src)-len("\n}\n"))
|
||||
|
||||
var items []CompletionItem
|
||||
for i := 0; i < 10; i++ {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
|
||||
var err error
|
||||
items, err = c.Completion(ctx, uri, pos)
|
||||
cancel()
|
||||
if err == nil && len(items) > 0 {
|
||||
break
|
||||
}
|
||||
time.Sleep(500 * time.Millisecond)
|
||||
}
|
||||
if len(items) == 0 {
|
||||
t.Fatal("没有补全结果")
|
||||
}
|
||||
withSnippet := 0
|
||||
for _, it := range items {
|
||||
if it.InsertTextFormat != 2 {
|
||||
continue
|
||||
}
|
||||
withSnippet++
|
||||
newText := ""
|
||||
if it.TextEdit != nil {
|
||||
newText = it.TextEdit.NewText
|
||||
}
|
||||
if !strings.Contains(newText, "${") {
|
||||
t.Errorf("format=2 但 textEdit.newText 里没有占位符:%q", newText)
|
||||
}
|
||||
}
|
||||
if withSnippet == 0 {
|
||||
t.Fatalf("snippetSupport 已开启,却没有任何 format=2 的补全项:%+v", items[:min(3, len(items))])
|
||||
}
|
||||
}
|
||||
@@ -85,14 +85,15 @@ func (m *MarkupContent) UnmarshalJSON(b []byte) error {
|
||||
|
||||
// CompletionItem 是一条补全建议。
|
||||
type CompletionItem struct {
|
||||
Label string `json:"label"`
|
||||
Kind int `json:"kind"`
|
||||
Detail string `json:"detail"`
|
||||
Documentation json.RawMessage `json:"documentation"`
|
||||
InsertText string `json:"insertText"`
|
||||
TextEdit *TextEdit `json:"textEdit"`
|
||||
FilterText string `json:"filterText"`
|
||||
SortText string `json:"sortText"`
|
||||
Label string `json:"label"`
|
||||
Kind int `json:"kind"`
|
||||
Detail string `json:"detail"`
|
||||
Documentation json.RawMessage `json:"documentation"`
|
||||
InsertText string `json:"insertText"`
|
||||
InsertTextFormat int `json:"insertTextFormat"` // 1=纯文本 2=snippet
|
||||
TextEdit *TextEdit `json:"textEdit"`
|
||||
FilterText string `json:"filterText"`
|
||||
SortText string `json:"sortText"`
|
||||
}
|
||||
|
||||
// CompletionList 是补全结果的一种包装。
|
||||
@@ -302,7 +303,7 @@ func defaultCapabilities() ClientCapabilities {
|
||||
Synchronization: SynchronizationCapabilities{DidSave: true},
|
||||
Completion: map[string]any{
|
||||
"completionItem": map[string]any{
|
||||
"snippetSupport": false,
|
||||
"snippetSupport": true,
|
||||
"documentationFormat": []string{"markdown", "plaintext"},
|
||||
},
|
||||
"contextSupport": true,
|
||||
|
||||
Reference in new issue
Block a user