fix: 按评估优先级修四项(标签右键/UTF-8 截断/覆盖率输出/.gitignore)
1. 标签页右键菜单接回(回归修复) tabmenu.go 的 160 行实现全库零调用点,tabBar 只处理 Clicked。 补 RightClicked → openPop(tabEntries(path)),右键时先设 active (菜单无标题,靠标签高亮传达「关闭左边」相对谁算)。 新增 tabmenu_test.go 8 个单测。 2. 中文按字节截断导致乱码 palette.go trimmed[:160]、rename.go s[:140] 会把多字节字符切断。 trimTo 从 gitlog.go 提到 strutil.go(三个调用方共用),两处改用它; n<=0 返回空串。strutil_test.go 6 个单测(含真实 linePreview 路径)。 3. 覆盖率运行不再吞测试输出 原来 lines 收集后 _ = lines 丢弃,测试失败只看到覆盖率数字。 改用 ExitCode() 判失败,只回放 FAIL/--- FAIL/panic/# 包/file.go:12 行 (上限 200),覆盖率页顶部给红底摘要 + 「查看测试输出」按钮。 coverageFailLines/Summary 纯函数 + 5 个单测。 4. 索引与搜索感知 .gitignore 新增 ignore.go:dir/、*.ext、/rootonly、带路径、**、! 取反、注释。 内置跳过扩到 vendor/dist/build/out/target/.next(文件树仍用保守 skipDir)。 indexState 加 truncated,快速打开底部提示「索引已截断至 N 个文件」。 ignore_test.go 10 个单测 + 真实遍历集成测试。 验证:go vet ./... 干净;go test ./internal/... 7 包全绿; e2e 实例 tools/tree 确认菜单 5 项齐全 + tools/shot 截图核对。
This commit is contained in:
1 parent
bbff08f364
commit
4ace9c9fb6
14 files changed
+965
-34
No files matched your search
+18
-9
@@ -209,24 +209,30 @@ func (a *App) workspaceFiles() []string {
|
||||
if files, ready := a.indexSnapshot(); ready {
|
||||
return files
|
||||
}
|
||||
rules := loadIgnoreRules(root)
|
||||
var files []string
|
||||
_ = filepath.WalkDir(root, func(p string, d os.DirEntry, err error) error {
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
rel, relErr := filepath.Rel(root, p)
|
||||
relSlash := ""
|
||||
if relErr == nil {
|
||||
relSlash = filepath.ToSlash(rel)
|
||||
}
|
||||
if d.IsDir() {
|
||||
if p != root && skipDir(d.Name()) {
|
||||
if p != root && (isBuiltinSkipDir(d.Name()) || rules.match(relSlash, true)) {
|
||||
return filepath.SkipDir
|
||||
}
|
||||
return nil
|
||||
}
|
||||
if skipFile(d.Name()) {
|
||||
if skipFile(d.Name()) || rules.match(relSlash, false) {
|
||||
return nil
|
||||
}
|
||||
if rel, err := filepath.Rel(root, p); err == nil {
|
||||
files = append(files, filepath.ToSlash(rel))
|
||||
if relErr == nil {
|
||||
files = append(files, relSlash)
|
||||
}
|
||||
if len(files) > 20000 {
|
||||
if len(files) > indexFileCap {
|
||||
return filepath.SkipAll
|
||||
}
|
||||
return nil
|
||||
@@ -261,10 +267,8 @@ func (a *App) searchInWorkspace(query string, limit int, o searchOpts) []palette
|
||||
if !match(line) {
|
||||
continue
|
||||
}
|
||||
trimmed := strings.TrimSpace(line)
|
||||
if len(trimmed) > 160 {
|
||||
trimmed = trimmed[:160] + "…"
|
||||
}
|
||||
// 按字符截断,别切坏中文(见 strutil.go 的注释)。
|
||||
trimmed := trimTo(strings.TrimSpace(line), 160)
|
||||
out = append(out, paletteItem{
|
||||
Kind: itemLine,
|
||||
Path: abs,
|
||||
@@ -419,6 +423,11 @@ func (a *App) paletteView(c *ui.Context) {
|
||||
ui.Text(c, "Enter 打开").FontSize(10).TextColor(t.TextMuted)
|
||||
ui.Text(c, "Esc 关闭").FontSize(10).TextColor(t.TextMuted)
|
||||
ui.Box(c).Grow(1)
|
||||
// 索引被上限截断时说一声:否则「搜不到」会被当成「不存在」。
|
||||
if !a.pal.search && a.indexTruncated() {
|
||||
ui.Textf(c, "索引已截断至 %d 个文件", indexFileCap).
|
||||
FontSize(10).TextColor(t.Warning)
|
||||
}
|
||||
if n := len(a.pal.items); n > 0 {
|
||||
ui.Textf(c, "%d 项", n).FontSize(10).TextColor(t.TextMuted)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user