From d6eebeb8ad4fcd94bf398dba233a4c88caae2a04 Mon Sep 17 00:00:00 2001 From: Joe Lim <50560759+joelim-work@users.noreply.github.com> Date: Fri, 29 May 2026 14:00:50 +1000 Subject: [PATCH] fix: handle missing cache during `fileChan` reload (#2602) When saving a file in a text editor, the modification will be reported in `fileChan` which then reloads the cached preview. However the preview may also end up getting deleted from the cache first if the text editor saves using a backup file instead of writing to the file directly. This commit simply adds back the cache entry as a fallback if it is missing. Maybe it's better to have a function similar to `getDir` that operates for reg previews (i.e. read-through cache). --- app.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app.go b/app.go index 618e7ddc..85ff36fc 100644 --- a/app.go +++ b/app.go @@ -468,6 +468,17 @@ 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)