@@ -15,31 +15,33 @@ func (h *handler) FilterItems(items []os.FileInfo) []os.FileInfo {
1515 filtered := make ([]os.FileInfo , 0 , len (items ))
1616
1717 for _ , item := range items {
18- shouldShow := true
19- if h .shows != nil {
20- shouldShow = shouldShow && h .shows .MatchString (item .Name ())
21- }
22- if h .showDirs != nil && item .IsDir () {
23- shouldShow = shouldShow && h .showDirs .MatchString (item .Name ())
18+ name := item .Name ()
19+
20+ if h .hides != nil && h .hides .MatchString (name ) {
21+ continue
2422 }
25- if h .showFiles != nil && ! item .IsDir () {
26- shouldShow = shouldShow && h .showFiles .MatchString (item .Name ())
23+
24+ if h .hideDirs != nil && item .IsDir () && h .hideDirs .MatchString (name ) {
25+ continue
2726 }
2827
29- shouldHide := false
30- if h .hides != nil {
31- shouldHide = shouldHide || h .hides .MatchString (item .Name ())
28+ if h .hideFiles != nil && ! item .IsDir () && h .hideFiles .MatchString (name ) {
29+ continue
3230 }
33- if h .hideDirs != nil && item .IsDir () {
34- shouldHide = shouldHide || h .hideDirs .MatchString (item .Name ())
31+
32+ if h .shows != nil && ! h .shows .MatchString (name ) {
33+ continue
3534 }
36- if h .hideFiles != nil && ! item .IsDir () {
37- shouldHide = shouldHide || h .hideFiles .MatchString (item .Name ())
35+
36+ if h .showDirs != nil && item .IsDir () && ! h .showDirs .MatchString (name ) {
37+ continue
3838 }
3939
40- if shouldShow && ! shouldHide {
41- filtered = append ( filtered , item )
40+ if h . showFiles != nil && ! item . IsDir () && ! h . showFiles . MatchString ( name ) {
41+ continue
4242 }
43+
44+ filtered = append (filtered , item )
4345 }
4446
4547 return filtered
0 commit comments