Skip to content

Commit 36fbd12

Browse files
committed
perf(tui): async file loading, LRU rendering cache, and bounded variant caps for full-file view
Fixes #833: Decouple synchronous file reading and Chroma highlighting from View() render loop into an async cache keyed by target path, size, modtime and diff fingerprint. - Bound total source bytes consumed with io.LimitReader and immediate cutoff on oversized physical lines (> fileViewMaxBytes). - Bound rendered ANSI variants per cache entry with a 4-slot LRU to prevent memory growth across window resizes or changed line mutations. - Bound memory with 4000 lines / 1 MiB total / 4 KiB line limits and evict cleanly on theme changes.
1 parent 27b319c commit 36fbd12

4 files changed

Lines changed: 663 additions & 59 deletions

File tree

‎internal/tui/export_test.go‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,15 @@ func (c *staticRenderCache) stats() renderCacheStats {
144144
return c.statsData
145145
}
146146

147+
func fileViewCacheStatsForTest() fileViewCacheStats {
148+
return defaultFileViewCache.stats()
149+
}
150+
151+
func resetFileViewCacheForTest() {
152+
defaultFileViewCache.clear()
153+
defaultFileViewCache.resetStats()
154+
}
155+
147156
func renderSelectableList(options selectableListOptions) string {
148157
if len(options.Items) == 0 {
149158
return ""

0 commit comments

Comments
 (0)