From 3e825d8490749ebb711e873140071f52a5353ea5 Mon Sep 17 00:00:00 2001 From: q3cpma Date: Tue, 7 May 2024 17:49:17 +0200 Subject: [PATCH] sort: no point in sorting with dirfirst if dironly --- nav.go | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/nav.go b/nav.go index f8dd4c8d..39b8436b 100644 --- a/nav.go +++ b/nav.go @@ -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 @@ -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