Skip to content

Commit fe9ee39

Browse files
committed
fix(nav): traversal skip (#363)
feat(nav): fix up SkipDir (#363) feat(nav): fix up pointer to slice (#363) feat(nav): move proxy method to frame (#363) feat(nav): make frame on navigation info private (#363) feat(nav): add SkipTraversal (#363) feat(nav): fix up traversal skip (#363)
1 parent e4bd397 commit fe9ee39

19 files changed

+312
-223
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ ginkgo.report
2020

2121
.task/
2222
.env
23+
.DS_Store
24+
thumbs.db
2325

2426
test-options*.json
2527
test-state*.json

.vscode/launch.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
55
"version": "0.2.0",
66
"configurations": [
7+
78
{
89
"name": "Launch Package",
910
"type": "go",

.vscode/settings.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,17 @@
77
"bodyclose",
88
"booter",
99
"bootstrapper",
10+
"cerr",
1011
"chardata",
12+
"cmds",
1113
"cobrass",
1214
"coverpkg",
1315
"coverprofile",
1416
"deadcode",
1517
"deepcopy",
1618
"depguard",
1719
"dogsled",
20+
"dotenv",
1821
"dupl",
1922
"ensync",
2023
"errcheck",
@@ -70,9 +73,11 @@
7073
"oldpath",
7174
"onecontext",
7275
"onsi",
76+
"outdir",
7377
"prealloc",
7478
"rabbitweed",
7579
"repath",
80+
"repotoken",
7681
"Resumer",
7782
"rxgo",
7883
"samber",
@@ -92,6 +97,11 @@
9297
"unparam",
9398
"usao",
9499
"varcheck",
100+
"watchv",
101+
"watchvc",
102+
"watchvi",
103+
"watchvn",
104+
"watchvu",
95105
"wgan",
96106
"xname",
97107
"xpander",

xfs/nav/directory-entries.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func (e *DirectoryEntries) arrange(entries *[]fs.DirEntry) {
6363
}
6464
}
6565

66-
func (e *DirectoryEntries) all() *[]fs.DirEntry {
66+
func (e *DirectoryEntries) all() []fs.DirEntry {
6767
result := []fs.DirEntry{}
6868

6969
switch e.Order {
@@ -73,7 +73,7 @@ func (e *DirectoryEntries) all() *[]fs.DirEntry {
7373
result = append(e.Files, e.Folders...) //nolint:gocritic // no alternative known
7474
}
7575

76-
return &result
76+
return result
7777
}
7878

7979
func (e *DirectoryEntries) sort(entries *[]fs.DirEntry) {

xfs/nav/error-handlers.go

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,13 @@ func (h *notifyCallbackErrorHandler) accept(params *fileSystemErrorParams) error
3333
},
3434
)
3535

36-
callbackErr := params.agent.proxy(&agentProxyParams{
37-
item: &TraverseItem{
38-
Path: params.path,
39-
Info: params.info,
40-
Error: err,
41-
Children: []fs.DirEntry{},
42-
Extension: &ExtendedItem{},
43-
},
44-
45-
frame: params.frame,
46-
})
36+
callbackErr := params.frame.proxy(&TraverseItem{
37+
Path: params.path,
38+
Info: params.info,
39+
Error: err,
40+
Children: []fs.DirEntry{},
41+
Extension: &ExtendedItem{},
42+
}, nil)
4743

4844
return callbackErr
4945
}

xfs/nav/errors.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package nav
22

33
import (
44
"fmt"
5-
"io/fs"
65
)
76

87
// ❌ Invalid Notification Mute Requested
@@ -52,10 +51,3 @@ func NewInvalidPeriscopeRootPathNativeError(root, current string) error {
5251
func NewResumeControllerNotSetNativeError(from string) error {
5352
return fmt.Errorf("internal: resume controller not set (from: '%v')", from)
5453
}
55-
56-
// ❌ SkipDir
57-
58-
// QuerySkipDirError query if error is the fs SkipDir error
59-
func QuerySkipDirError(target error) bool {
60-
return target != nil && target == fs.SkipDir
61-
}

xfs/nav/helpers_test.go

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,11 @@ type naviTE struct {
4545

4646
type skipTE struct {
4747
naviTE
48-
skip string
49-
exclude string
48+
skipAt string
49+
prohibit string
50+
all bool
51+
folderCount int
52+
fileCount int
5053
}
5154

5255
type listenTE struct {
@@ -368,12 +371,12 @@ func foldersCaseSensitiveCallback(first, second string) *nav.LabelledTraverseCal
368371

369372
// === skip
370373

371-
func skipFolderCallback(skip, exclude string) *nav.LabelledTraverseCallback {
374+
func skipDirFolderCallback(skip, exclude string) *nav.LabelledTraverseCallback {
372375
return &nav.LabelledTraverseCallback{
373376
Label: "test skip folder callback",
374377
Fn: func(item *nav.TraverseItem) error {
375378
GinkgoWriter.Printf(
376-
"---> ♻️ ON-NAVIGATOR-SKIP-CALLBACK(skip:%v): '%v'\n", skip, item.Path,
379+
"---> ♻️ ON-NAVIGATOR-SKIP-DIR-CALLBACK(skip:%v): '%v'\n", skip, item.Path,
377380
)
378381

379382
Expect(strings.HasSuffix(item.Path, exclude)).To(BeFalse())
@@ -385,6 +388,23 @@ func skipFolderCallback(skip, exclude string) *nav.LabelledTraverseCallback {
385388
}
386389
}
387390

391+
func skipAllFolderCallback(skip, exclude string) *nav.LabelledTraverseCallback {
392+
return &nav.LabelledTraverseCallback{
393+
Label: "test skipAll folder callback",
394+
Fn: func(item *nav.TraverseItem) error {
395+
GinkgoWriter.Printf(
396+
"---> ♻️ ON-NAVIGATOR-SKIP-ALL-CALLBACK(skip:%v): '%v'\n", skip, item.Path,
397+
)
398+
399+
Expect(strings.HasSuffix(item.Path, exclude)).To(BeFalse())
400+
401+
return lo.Ternary(strings.HasSuffix(item.Path, skip),
402+
fs.SkipAll, nil,
403+
)
404+
},
405+
}
406+
}
407+
388408
func boostCallback(name string) *nav.LabelledTraverseCallback {
389409
return &nav.LabelledTraverseCallback{
390410
Label: "test boost callback",

xfs/nav/hook-extend.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,22 @@ func DefaultExtendHookFn(navi *NavigationInfo, entries *DirectoryEntries) {
2323

2424
if navi.Item.IsDir() {
2525
isLeaf = len(entries.Folders) == 0
26-
scope = navi.Frame.periscope.scope(isLeaf)
26+
scope = navi.frame.periscope.scope(isLeaf)
2727
} else {
2828
scope = ScopeLeafEn
2929
}
3030

3131
parent, name := filepath.Split(navi.Item.Path)
3232
navi.Item.Extension = &ExtendedItem{
33-
Depth: navi.Frame.periscope.depth(),
33+
Depth: navi.frame.periscope.depth(),
3434
IsLeaf: isLeaf,
3535
Name: name,
3636
Parent: parent,
3737
NodeScope: scope,
3838
}
3939

4040
spInfo := &SubPathInfo{
41-
Root: navi.Frame.root.Get(),
41+
Root: navi.frame.root.Get(),
4242
Item: navi.Item,
4343
Behaviour: &navi.Options.Store.Behaviours.SubPath,
4444
}

0 commit comments

Comments
 (0)