From f01fab6257864aeb3a305f681580edda90a79ce4 Mon Sep 17 00:00:00 2001 From: Gokcehan Date: Sat, 9 Oct 2021 22:49:12 +0300 Subject: [PATCH] fix crash when hidden is changed cc #615 #657 --- nav.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/nav.go b/nav.go index ffa21d6..3f4cd8a 100644 --- a/nav.go +++ b/nav.go @@ -280,6 +280,9 @@ func (dir *dir) sort() { dir.files = dir.files[len(dir.files):] } } + + dir.ind = max(dir.ind, 0) + dir.ind = min(dir.ind, len(dir.files)-1) } func (dir *dir) name() string { @@ -287,9 +290,6 @@ func (dir *dir) name() string { return "" } - dir.ind = max(dir.ind, 0) - dir.ind = min(dir.ind, len(dir.files)-1) - return dir.files[dir.ind].Name() } @@ -1414,6 +1414,7 @@ func (nav *nav) currFile() (*file, error) { if len(dir.files) == 0 { return nil, fmt.Errorf("empty directory") } + return dir.files[dir.ind], nil }