From 1223b5338bd8d97c31bf02e60bb6ff65792ad371 Mon Sep 17 00:00:00 2001 From: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> Date: Thu, 9 Apr 2026 19:10:34 +1000 Subject: [PATCH] fix: prevent cacheBuffer from extending viewport over height --- plugin/src/Caelestia/Components/lazylistview.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/plugin/src/Caelestia/Components/lazylistview.cpp b/plugin/src/Caelestia/Components/lazylistview.cpp index 14fb4bb8..edcef17d 100644 --- a/plugin/src/Caelestia/Components/lazylistview.cpp +++ b/plugin/src/Caelestia/Components/lazylistview.cpp @@ -507,7 +507,19 @@ QRectF LazyListView::effectiveViewport() const { vp = QRectF(vp.x(), top, vp.width(), bottom - top); } - return vp.adjusted(0, -m_cacheBuffer, 0, m_cacheBuffer); + vp.adjust(0, -m_cacheBuffer, 0, m_cacheBuffer); + + // Trim the cache-buffered viewport to [0, layoutHeight]. No items exist outside + // those bounds, so extending past them wastes budget and can cause edge thrashing + // when a large cache buffer reaches the opposite end of the content. + if (m_layoutHeight > 0) { + const qreal top = std::max(vp.y(), 0.0); + const qreal bottom = std::min(vp.y() + vp.height(), m_layoutHeight); + if (top < bottom) + vp = QRectF(vp.x(), top, vp.width(), bottom - top); + } + + return vp; } std::pair LazyListView::computeVisibleRange() const {