From 3b043752a4649d0b5202fcd8267d721b702b575b Mon Sep 17 00:00:00 2001 From: Gokcehan Date: Fri, 20 Apr 2018 21:28:56 +0300 Subject: [PATCH] sort cached directories asynchronously --- nav.go | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/nav.go b/nav.go index 4aad832..783c5f9 100644 --- a/nav.go +++ b/nav.go @@ -330,15 +330,22 @@ func (nav *nav) loadDir(path string) *dir { d.ind, d.pos = 0, 0 nav.dirChan <- d }() - d := &dir{loading: true, path: path} + d := &dir{loading: true, path: path, sortType: gOpts.sortType} nav.dirCache[path] = d return d } + if d.sortType != gOpts.sortType { - name := d.name() - d.sort() - d.find(name, nav.height) + go func() { + d.loading = true + name := d.name() + d.sort() + d.find(name, nav.height) + d.loading = false + nav.dirChan <- d + }() } + return d }