From bcd058ace25873d1ac015f0e28fb1ddf9d4865a3 Mon Sep 17 00:00:00 2001 From: Joe Lim <50560759+joelim-work@users.noreply.github.com> Date: Sun, 12 Mar 2023 23:11:09 +1100 Subject: [PATCH] Delete stale dircache entry during rename (#1138) * Delete stale dircache entry during rename * Clear `regCache` as well * Add comment --- nav.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/nav.go b/nav.go index a08238d7..6184887c 100644 --- a/nav.go +++ b/nav.go @@ -1434,6 +1434,12 @@ func (nav *nav) rename() error { return err } + // It is possible for newPath to already have cache entries if it previously + // existed and was deleted. In this case the cache entries should be deleted + // before loading newPath to prevent displaying a stale preview. However, + // this clears only the current instance of lf, and not any other instances. + delete(nav.regCache, newPath) + delete(nav.dirCache, newPath) dir := nav.loadDir(filepath.Dir(newPath)) if dir.loading {