diff --git a/nav.go b/nav.go index f4f1287b..de70595e 100644 --- a/nav.go +++ b/nav.go @@ -142,6 +142,18 @@ func (file *file) TotalSize() int64 { return file.Size() } +func (file *file) isPreviewable() bool { + if file.Mode().IsRegular() { + return true + } + + if file.IsDir() && gOpts.dirpreviews { + return true + } + + return false +} + type fakeStat struct { name string } @@ -806,7 +818,7 @@ func (nav *nav) preload() { } file := dir.files[i] - if !(file.Mode().IsRegular() || (file.IsDir() && gOpts.dirpreviews)) { + if !file.isPreviewable() { return } diff --git a/ui.go b/ui.go index c2aa2b10..e122d933 100644 --- a/ui.go +++ b/ui.go @@ -797,7 +797,7 @@ func (ui *ui) loadFile(app *app, volatile bool) { return } - if curr.Mode().IsRegular() || (curr.IsDir() && gOpts.dirpreviews) { + if curr.isPreviewable() { ui.regPrev = app.nav.loadReg(curr.path, volatile) } else if curr.IsDir() { ui.dirPrev = app.nav.loadDir(curr.path) @@ -1294,7 +1294,7 @@ func (ui *ui) draw(nav *nav) { preview := ui.wins[len(ui.wins)-1] ui.sxScreen.clearSixel(preview, ui.screen, curr.path) if gOpts.preview { - if curr.Mode().IsRegular() || (curr.IsDir() && gOpts.dirpreviews) { + if curr.isPreviewable() { preview.printReg(ui.screen, ui.regPrev, nav.previewLoading, &ui.sxScreen) } else if curr.IsDir() { ui.sxScreen.lastFile = ""