From 1cee8b9d9c130a98b14b0252ff6f12c2520210b1 Mon Sep 17 00:00:00 2001 From: Gokcehan Date: Wed, 5 Oct 2016 18:36:12 +0300 Subject: [PATCH] handle symbolic links to directories for previews Mentioned in #24 and #25. --- ui.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/ui.go b/ui.go index 9e5ae6b..c1da67b 100644 --- a/ui.go +++ b/ui.go @@ -399,11 +399,19 @@ func (ui *UI) loadFile(nav *Nav) { path := nav.currPath() - if curr.IsDir() { + f, err := os.Stat(path) + if err != nil { + msg := fmt.Sprintf("getting file information: %s", err) + ui.message = msg + log.Print(msg) + return + } + + if f.IsDir() { dir := newDir(path) dir.load(nav.inds[path], nav.poss[path], nav.height, nav.names[path]) ui.dirprev = dir - } else if curr.Mode().IsRegular() { + } else if f.Mode().IsRegular() { var reader io.Reader if len(gOpts.previewer) != 0 {