mirror of
https://github.com/esengine/DeepSeek-Reasonix.git
synced 2026-11-07 10:45:59 -10:00
Merge pull request #10774 from esengine/fix/v1-10006-panel-shows-tmp-bin-stage
fix(desktop): the file panel shows top-level tmp/, bin/ and stage/
This commit is contained in:
6 files changed
+78
-31
No files matched your search
+1
-13
@@ -9841,18 +9841,6 @@ func previewMediaKind(path string) (kind string, mime string) {
|
||||
return "", ""
|
||||
}
|
||||
|
||||
func workspaceEntryRel(rel, name string) string {
|
||||
rel = strings.Trim(filepath.ToSlash(rel), "/")
|
||||
if rel == "" || rel == "." {
|
||||
return name
|
||||
}
|
||||
return rel + "/" + name
|
||||
}
|
||||
|
||||
func skipWorkspaceEntry(rel, name string, isDir bool) bool {
|
||||
return fileref.SkipEntry(workspaceEntryRel(rel, name), name, isDir)
|
||||
}
|
||||
|
||||
func (a *App) activeWorkspaceBase() (string, error) {
|
||||
return workspaceBaseFromRoot(a.activeWorkspaceRoot())
|
||||
}
|
||||
@@ -9943,7 +9931,7 @@ func listDirForWorkspaceTarget(base string, ctrl control.SessionAPI, rel string)
|
||||
dirs, files := []DirEntry{}, []DirEntry{}
|
||||
for _, e := range es {
|
||||
name := e.Name()
|
||||
if skipWorkspaceEntry(rel, name, e.IsDir()) {
|
||||
if fileref.SkipBrowseEntry(name, e.IsDir()) {
|
||||
continue
|
||||
}
|
||||
if e.IsDir() {
|
||||
|
||||
+5
-5
@@ -5699,14 +5699,14 @@ func TestSearchFileRefsFindsNestedBasename(t *testing.T) {
|
||||
|
||||
app := &App{}
|
||||
listed := app.ListDir("")
|
||||
for _, hidden := range []string{".codex", ".npm", ".pnpm-store", "bin", "dist", "stage", "tmp"} {
|
||||
if hasDirEntry(listed, hidden) {
|
||||
t.Fatalf("ListDir should hide local noise %q, got %+v", hidden, listed)
|
||||
for name, shown := range map[string]bool{".codex": false, ".npm": false, ".pnpm-store": false, "dist": false, "bin": true, "stage": true, "tmp": true} {
|
||||
if hasDirEntry(listed, name) != shown {
|
||||
t.Fatalf("ListDir shows %q = %v, want %v (only @-search skips generic names); got %+v", name, !shown, shown, listed)
|
||||
}
|
||||
}
|
||||
desktopFrontend := app.ListDir("desktop/frontend")
|
||||
if hasDirEntry(desktopFrontend, "wailsjs") {
|
||||
t.Fatalf("ListDir should hide generated Wails bindings, got %+v", desktopFrontend)
|
||||
if !hasDirEntry(desktopFrontend, "wailsjs") {
|
||||
t.Fatalf("ListDir should show desktop/frontend/wailsjs, got %+v", desktopFrontend)
|
||||
}
|
||||
frontendEntries := app.ListDir("frontend")
|
||||
for _, hidden := range []string{".DS_Store", "Thumbs.db"} {
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestWorkspacePanelListsGenericTopLevelDirectories(t *testing.T) {
|
||||
base := t.TempDir()
|
||||
for _, dir := range []string{"tmp", "bin", "stage", "src", "node_modules", "dist"} {
|
||||
if err := os.MkdirAll(filepath.Join(base, dir), 0o755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
if err := os.WriteFile(filepath.Join(base, "main.py"), []byte("x"), 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
listed := map[string]bool{}
|
||||
for _, e := range listDirForWorkspaceTarget(base, nil, "") {
|
||||
listed[e.Name] = true
|
||||
}
|
||||
for _, want := range []string{"tmp", "bin", "stage", "src", "main.py"} {
|
||||
if !listed[want] {
|
||||
t.Errorf("file panel hides %q, a real workspace entry; listed %v", want, listed)
|
||||
}
|
||||
}
|
||||
for _, hidden := range []string{"node_modules", "dist"} {
|
||||
if listed[hidden] {
|
||||
t.Errorf("file panel lists %q, which stays hidden as vendor/build output", hidden)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestWorkspaceWatchSeesChangesUnderGenericTopLevelDirectories(t *testing.T) {
|
||||
root := t.TempDir()
|
||||
for _, rel := range []string{"tmp/notes.py", "bin/run.sh", "stage/plan.md"} {
|
||||
if workspaceWatchPathSkipped(root, filepath.Join(root, filepath.FromSlash(rel))) {
|
||||
t.Errorf("a change to %s is dropped although the file panel shows it", rel)
|
||||
}
|
||||
}
|
||||
if !workspaceWatchPathSkipped(root, filepath.Join(root, "node_modules", "x", "index.js")) {
|
||||
t.Error("changes under node_modules must stay ignored")
|
||||
}
|
||||
}
|
||||
@@ -137,11 +137,7 @@ func (h *workspaceChangeHub) addTreeLocked(r *workspaceWatchRoot, root string) {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
rel, relErr := filepath.Rel(r.root, path)
|
||||
if relErr != nil {
|
||||
return nil
|
||||
}
|
||||
if path != r.root && fileref.SkipEntry(filepath.ToSlash(rel), d.Name(), d.IsDir()) {
|
||||
if path != r.root && fileref.SkipBrowseEntry(d.Name(), d.IsDir()) {
|
||||
if d.IsDir() {
|
||||
return filepath.SkipDir
|
||||
}
|
||||
@@ -296,8 +292,7 @@ func workspaceWatchPathSkipped(root, path string) bool {
|
||||
}
|
||||
parts := strings.Split(filepath.ToSlash(rel), "/")
|
||||
for i, name := range parts {
|
||||
prefix := strings.Join(parts[:i+1], "/")
|
||||
if fileref.SkipEntry(prefix, name, i < len(parts)-1) {
|
||||
if fileref.SkipBrowseEntry(name, i < len(parts)-1) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,15 +37,21 @@ var skipDirNames = map[string]bool{
|
||||
".dart_tool": true,
|
||||
}
|
||||
|
||||
// SkipEntry reports whether a workspace entry is hidden from file pickers. rel
|
||||
// is the entry's slash-separated path from the workspace root.
|
||||
// SkipEntry reports whether a workspace entry is hidden from "@" reference
|
||||
// search. rel is the entry's slash-separated path from the workspace root.
|
||||
func SkipEntry(rel, name string, isDir bool) bool {
|
||||
if skipEntryNames[name] {
|
||||
return true
|
||||
}
|
||||
return isDir && (skipDirNames[name] || skipDirPaths[rel])
|
||||
return SkipBrowseEntry(name, isDir) || (isDir && skipDirPaths[rel])
|
||||
}
|
||||
|
||||
// SkipBrowseEntry reports whether a workspace entry is hidden from browsing
|
||||
// surfaces that mirror the disk, such as a file tree.
|
||||
func SkipBrowseEntry(name string, isDir bool) bool {
|
||||
return skipEntryNames[name] || (isDir && skipDirNames[name])
|
||||
}
|
||||
|
||||
// skipDirPaths are generated-output paths of this repository; their generic
|
||||
// names ("tmp", "bin") are hand-edited directories elsewhere, so only search
|
||||
// may skip them.
|
||||
var skipDirPaths = map[string]bool{
|
||||
"bin": true,
|
||||
"desktop/frontend/wailsjs": true, // retired Wails-generated bindings (stale dirs on old checkouts)
|
||||
|
||||
@@ -42,3 +42,15 @@ func TestSearchSkipsGeneratedClassFiles(t *testing.T) {
|
||||
t.Fatalf("the source file should still match: %v", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSearchSkipsRepoOutputPathsThatBrowsingShows(t *testing.T) {
|
||||
root := t.TempDir()
|
||||
writeFile(t, filepath.Join(root, "tmp", "scratch_notes.py"))
|
||||
|
||||
if got := resultPaths(Search(root, "scratch", 50)); len(got) != 0 {
|
||||
t.Fatalf("@ search must keep skipping top-level tmp/: %v", got)
|
||||
}
|
||||
if SkipBrowseEntry("tmp", true) {
|
||||
t.Fatal("a browsing surface must show a top-level tmp/ directory")
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user