Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Taking hidden files parameter into account in windows #1684

Merged
merged 5 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc.md
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,7 @@ Otherwise, these characters are interpreted as they are.

Show hidden files.
On Unix systems, hidden files are determined by the value of `hiddenfiles`.
On Windows, only files with hidden attributes are considered hidden files.
On Windows, files with hidden attributes are also considered hidden files.

## hiddenfiles ([]string) (default `.*`)

Expand Down
1 change: 0 additions & 1 deletion nav.go
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,6 @@ func (nav *nav) previewLoop(ui *ui) {
}
}

//lint:ignore U1000 This function is not used on Windows
func matchPattern(pattern, name, path string) bool {
s := name

Expand Down
17 changes: 16 additions & 1 deletion os_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,22 @@ func isHidden(f os.FileInfo, path string, hiddenfiles []string) bool {
if err != nil {
return false
}
return attrs&windows.FILE_ATTRIBUTE_HIDDEN != 0

if attrs&windows.FILE_ATTRIBUTE_HIDDEN != 0 {
return true
}

hidden := false
for _, pattern := range hiddenfiles {
matched := matchPattern(strings.TrimPrefix(pattern, "!"), f.Name(), path)
if strings.HasPrefix(pattern, "!") && matched {
hidden = false
} else if matched {
hidden = true
}
}

return hidden
}

func userName(f os.FileInfo) string {
Expand Down