完成待办清单全部 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
+42
-3
@@ -3,6 +3,7 @@ package app
|
||||
import (
|
||||
"crypto/sha1"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@@ -44,6 +45,19 @@ type histIndex struct {
|
||||
Entries []histEntry `json:"entries"`
|
||||
}
|
||||
|
||||
// histSkipped 不是写失败,而是「这次故意没留历史点」,需要让用户知道原因。
|
||||
// 用独立类型把它和真正的 IO 错误分开:前者进输出面板,后者进日志。
|
||||
type histSkipped struct{ msg string }
|
||||
|
||||
func (e histSkipped) Error() string { return e.msg }
|
||||
|
||||
// histSkipMessage 说明为什么这个文件没被纳入本地历史。
|
||||
// 单列成纯函数是为了能测:措辞里要带文件名、上限,别只说「失败」。
|
||||
func histSkipMessage(path string, size int) string {
|
||||
return fmt.Sprintf("本地历史:%s 超过 %d MB 上限(当前 %.1f MB),该文件不会有历史快照",
|
||||
filepath.Base(path), histMaxSize/(1<<20), float64(size)/(1<<20))
|
||||
}
|
||||
|
||||
// histMu 串行化索引读写:多个文档同时保存会并发进来。
|
||||
var histMu sync.Mutex
|
||||
|
||||
@@ -58,10 +72,17 @@ func historyDir(path string) string {
|
||||
}
|
||||
|
||||
// saveSnapshot 给文件留一个历史点;内容没变时直接跳过。
|
||||
//
|
||||
// 超过 histMaxSize 时返回 histSkipped(不是 error 日志),调用方要把它
|
||||
// 转成用户可见的说明——以前这里静默 return nil,大文件改坏后用户根本
|
||||
// 不知道自己没有快照可回。
|
||||
func saveSnapshot(path string, data []byte, reason string, dirty bool) error {
|
||||
if len(data) == 0 || len(data) > histMaxSize {
|
||||
if len(data) == 0 {
|
||||
return nil
|
||||
}
|
||||
if len(data) > histMaxSize {
|
||||
return histSkipped{histSkipMessage(path, len(data))}
|
||||
}
|
||||
dir := historyDir(path)
|
||||
if dir == "" {
|
||||
return nil
|
||||
@@ -225,7 +246,15 @@ func loadPending() []pendingSnap {
|
||||
return items
|
||||
}
|
||||
|
||||
// snapshotAsync 在后台给文档留一个历史点,失败只记日志。
|
||||
// shouldWarnHistory 判断这个文件的「超限」提示是否还没发过。
|
||||
// LoadOrStore 保证并发自动快照里也只过一次。
|
||||
func (a *App) shouldWarnHistory(path string) bool {
|
||||
_, warned := a.histWarned.LoadOrStore(path, struct{}{})
|
||||
return !warned
|
||||
}
|
||||
|
||||
// snapshotAsync 在后台给文档留一个历史点,真正的写失败只记日志;
|
||||
// 「故意跳过」要让用户看见,否则用户会以为自己有快照可回。
|
||||
func (a *App) snapshotAsync(d *Doc, reason string, dirty bool) {
|
||||
if d == nil || d.truncated || !a.set.History {
|
||||
return
|
||||
@@ -240,7 +269,17 @@ func (a *App) snapshotAsync(d *Doc, reason string, dirty bool) {
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if err := saveSnapshot(path, data, reason, dirty); err != nil {
|
||||
err = saveSnapshot(path, data, reason, dirty)
|
||||
var skipped histSkipped
|
||||
if errors.As(err, &skipped) {
|
||||
if a.win == nil || !a.shouldWarnHistory(path) {
|
||||
return
|
||||
}
|
||||
msg := skipped.Error()
|
||||
a.win.Update(func() { a.appendOut(msg) })
|
||||
return
|
||||
}
|
||||
if err != nil {
|
||||
logf("本地历史写入失败:%v", err)
|
||||
}
|
||||
}()
|
||||
|
||||
Reference in new issue
Block a user