Debounce resize triggers when preloading (#2240)

* Debounce resize triggers when preloading

* Clear all previews in cache
This commit is contained in:
Joe Lim authored and GitHub committed 2025-10-30 13:52:29 +11:00
1 parent 49984bb606
commit 5ae9a4cd81
2 files changed
+6 -8

No files matched your search

+2
View File
@@ -516,6 +516,8 @@ func (app *app) loop() {
case <-app.nav.previewTimer.C: case <-app.nav.previewTimer.C:
app.nav.previewLoading = true app.nav.previewLoading = true
app.ui.draw(app.nav) app.ui.draw(app.nav)
case <-app.nav.preloadTimer.C:
app.nav.preload()
} }
} }
} }
+4 -8
View File
@@ -494,6 +494,7 @@ type nav struct {
volatilePreview bool volatilePreview bool
previewTimer *time.Timer previewTimer *time.Timer
previewLoading bool previewLoading bool
preloadTimer *time.Timer
jumpList []string jumpList []string
jumpListInd int jumpListInd int
} }
@@ -618,6 +619,7 @@ func newNav(ui *ui) *nav {
tags: make(map[string]string), tags: make(map[string]string),
selectionInd: 0, selectionInd: 0,
previewTimer: time.NewTimer(0), previewTimer: time.NewTimer(0),
preloadTimer: time.NewTimer(0),
jumpList: make([]string, 0), jumpList: make([]string, 0),
jumpListInd: -1, jumpListInd: -1,
} }
@@ -696,14 +698,8 @@ func (nav *nav) resize(ui *ui) {
dir.boundPos(nav.height) dir.boundPos(nav.height)
} }
for path, r := range nav.regCache { clear(nav.regCache)
// keep volatile previews to prevent unnecessary preloads nav.preloadTimer.Reset(200 * time.Millisecond)
if !r.volatile {
delete(nav.regCache, path)
}
}
nav.preload()
} }
func (nav *nav) position() { func (nav *nav) position() {