From 9a3b84e672fd0dd31f0f7dedd6c659934f6c04dc Mon Sep 17 00:00:00 2001 From: valoq Date: Fri, 31 Jul 2026 09:06:12 +0200 Subject: [PATCH] fix: restrict preloading files (#2648) * fix: restric preloading files * improve patch --- app.go | 11 ----------- ui.go | 7 +++++-- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/app.go b/app.go index 725962b0..4bd9b3ed 100644 --- a/app.go +++ b/app.go @@ -471,17 +471,6 @@ func (app *app) loop() { if r, ok := app.nav.regCache[f.path]; ok { app.nav.checkReg(r) - } else { - r = ®{loading: true, loadTime: time.Now(), path: f.path} - app.nav.regCache[f.path] = r - if gOpts.preload { - select { - case app.nav.preloadChan <- f.path: - default: - } - } else { - app.nav.previewChan <- f.path - } } onLoad(app, []string{f.path}) app.ui.draw(app.nav) diff --git a/ui.go b/ui.go index 6e4c2d0e..a3472686 100644 --- a/ui.go +++ b/ui.go @@ -1028,9 +1028,12 @@ func (ui *ui) drawPreview(nav *nav, context *dirContext) { if gOpts.preview { if curr.isPreviewable() { - if reg, ok := nav.regCache[curr.path]; ok { - win.printReg(ui.screen, reg, &ui.sxScreen, nav.previewTimer) + reg, ok := nav.regCache[curr.path] + if !ok { + // the shown file can lose its cache entry, e.g. a save that deletes and recreates it + reg = nav.loadReg(curr.path, false) } + win.printReg(ui.screen, reg, &ui.sxScreen, nav.previewTimer) } else if curr.IsDir() { ui.sxScreen.lastFile = "" dir := nav.getDir(curr.path)