Skip to content

Commit

Permalink
sort: don't double sort when dirfirst is set
Browse files Browse the repository at this point in the history
  • Loading branch information
q3cpma committed May 7, 2024
1 parent 2a0c85d commit 0ea3551
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions nav.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,12 +278,12 @@ func (dir *dir) sort() {
return oldlessfun(j, i)
}
}
sort.SliceStable(dir.files, lessfun)

// when dironly option is enabled, we move files to the beginning of our file
// list and then set the beginning of displayed files to the first directory
// in the list
if dir.dironly {
sort.SliceStable(dir.files, lessfun)
sort.SliceStable(dir.files, func(i, j int) bool {
if !dir.files[i].IsDir() && !dir.files[j].IsDir() {
return i < j
Expand All @@ -301,7 +301,7 @@ func (dir *dir) sort() {
} else if dir.dirfirst {
sort.SliceStable(dir.files, func(i, j int) bool {
if dir.files[i].IsDir() == dir.files[j].IsDir() {
return i < j
return lessfun(i, j)
}
return dir.files[i].IsDir()
})
Expand Down

0 comments on commit 0ea3551

Please sign in to comment.