From 4d951130a5e3fa6e9015ddf78d7e75d9319b9897 Mon Sep 17 00:00:00 2001 From: FragginWagon Date: Wed, 28 Jan 2026 20:33:33 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=8D=20Improve=20scrolling=20logic=20to?= =?UTF-8?q?=20dynamically=20load=20more=20lines=20when=20searching=20resul?= =?UTF-8?q?ts=20exceed=20displayed=20lines?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pokedex.online/src/views/GamemasterExplorer.vue | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/code/websites/pokedex.online/src/views/GamemasterExplorer.vue b/code/websites/pokedex.online/src/views/GamemasterExplorer.vue index 14e42bb..2163fc3 100644 --- a/code/websites/pokedex.online/src/views/GamemasterExplorer.vue +++ b/code/websites/pokedex.online/src/views/GamemasterExplorer.vue @@ -677,6 +677,17 @@ function scrollToResult() { const lineNumber = lineIndex + 1; // Convert to 1-based line number + // If result is beyond currently displayed lines, load more lines + if (lineIndex >= displayLines.value.length && lineIndex < fileLines.value.length) { + // Expand displayLines to include the result + const newLinesToDisplay = fileLines.value.slice(0, Math.min(lineIndex + 1000, fileLines.value.length)); + displayLines.value = newLinesToDisplay.map((content, index) => ({ + lineNumber: index + 1, + content, + hasMatch: searchResults.value.includes(index) + })); + } + // Retry logic for virtual scroller rendering const attemptScroll = (attempt = 0) => { const lineElement = document.querySelector(`[data-line="${lineNumber}"]`); @@ -694,7 +705,7 @@ function scrollToResult() { const container = document.querySelector('.scroller, .lines-container'); if (container) { const estimatedScroll = - (lineIndex / displayLines.value.length) * + (lineIndex / fileLines.value.length) * (container.scrollHeight - container.clientHeight); container.scrollTop = estimatedScroll; }