Skip to content

Commit

Permalink
sort: no point in sorting with dirfirst if dironly
Browse files Browse the repository at this point in the history
  • Loading branch information
q3cpma committed May 8, 2024
1 parent 0a6ec54 commit 3e825d8
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions nav.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,15 +279,6 @@ func (dir *dir) sort() {
}
sort.SliceStable(dir.files, lessfun)

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 dir.files[i].IsDir()
})
}

// 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
Expand All @@ -306,6 +297,13 @@ func (dir *dir) sort() {
}
return dir.files[len(dir.files):]
}()
} 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 dir.files[i].IsDir()
})
}

// when hidden option is disabled, we move hidden files to the
Expand Down

0 comments on commit 3e825d8

Please sign in to comment.