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 项规划与完成索引。
75 lines
2.2 KiB
Go
75 lines
2.2 KiB
Go
package app
|
||
|
||
import (
|
||
"fmt"
|
||
"os"
|
||
"path/filepath"
|
||
"strings"
|
||
"testing"
|
||
)
|
||
|
||
// TestSearchConcurrentOrderStable 并发读盘后结果仍按文件序排列,
|
||
// 不能因为哪个 worker 先跑完就打乱顺序。
|
||
func TestSearchConcurrentOrderStable(t *testing.T) {
|
||
root := t.TempDir()
|
||
const n = 24
|
||
for i := 0; i < n; i++ {
|
||
name := fmt.Sprintf("f%02d.txt", i)
|
||
body := fmt.Sprintf("line one\nneedle in %s\nlast line\n", name)
|
||
if err := os.WriteFile(filepath.Join(root, name), []byte(body), 0o644); err != nil {
|
||
t.Fatal(err)
|
||
}
|
||
}
|
||
a := &App{root: root}
|
||
got, stats := a.searchInWorkspace("needle", 200, searchOpts{})
|
||
if len(got) != n {
|
||
t.Fatalf("应命中 %d 行,实际 %d", n, len(got))
|
||
}
|
||
if stats.hint() != "" {
|
||
t.Fatalf("没有跳过文件时不该有提示:%q", stats.hint())
|
||
}
|
||
for i, it := range got {
|
||
want := fmt.Sprintf("f%02d.txt", i)
|
||
if it.Label != want {
|
||
t.Fatalf("第 %d 项是 %q,想要 %q(顺序乱了)", i, it.Label, want)
|
||
}
|
||
if it.Line != 2 {
|
||
t.Fatalf("%s 命中行 = %d,想要 2", it.Label, it.Line)
|
||
}
|
||
}
|
||
}
|
||
|
||
// TestSearchStatsTooLarge 超过 512KB 的文件要被数出来,并且提示可见。
|
||
func TestSearchStatsTooLarge(t *testing.T) {
|
||
root := t.TempDir()
|
||
big := strings.Repeat("x", 512*1024+1) + "\nneedle\n"
|
||
if err := os.WriteFile(filepath.Join(root, "big.txt"), []byte(big), 0o644); err != nil {
|
||
t.Fatal(err)
|
||
}
|
||
if err := os.WriteFile(filepath.Join(root, "small.txt"), []byte("needle\n"), 0o644); err != nil {
|
||
t.Fatal(err)
|
||
}
|
||
a := &App{root: root}
|
||
got, stats := a.searchInWorkspace("needle", 200, searchOpts{})
|
||
if len(got) != 1 || got[0].Label != "small.txt" {
|
||
t.Fatalf("只该命中 small.txt:%+v", got)
|
||
}
|
||
if stats.tooLarge != 1 {
|
||
t.Fatalf("tooLarge = %d,想要 1", stats.tooLarge)
|
||
}
|
||
hint := stats.hint()
|
||
if !strings.Contains(hint, "512 KB") || !strings.Contains(hint, "1 个文件") {
|
||
t.Fatalf("提示没说清跳过了什么:%q", hint)
|
||
}
|
||
}
|
||
|
||
func TestSearchStatsHint(t *testing.T) {
|
||
if (searchStats{}).hint() != "" {
|
||
t.Fatal("没有跳过时不该有提示")
|
||
}
|
||
h := (searchStats{tooLarge: 2, unreadable: 3}).hint()
|
||
if !strings.Contains(h, "2 个文件超过 512 KB") || !strings.Contains(h, "3 个文件读不出") {
|
||
t.Fatalf("提示缺内容:%q", h)
|
||
}
|
||
}
|