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

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