Skip to content

Commit 14d6a00

Browse files
JohnMcLearclaude
andcommitted
fix: inclusive visible-line range in page up/down sizing
Addresses Qodo review: scroll.getVisibleLineRange() returns an inclusive end index, but visibleLogicalLines was computed as (end - start), which is one fewer than the logical lines actually summed into totalPixelHeight. The viewport ratio therefore underestimated the page increment by one line in the common case. Use (end - start + 1) to match the loop bounds. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 430ebdd commit 14d6a00

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

src/static/js/ace2_inner.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2880,7 +2880,10 @@ function Ace2Inner(editorInfo, cssManagers) {
28802880
totalPixelHeight += entry.lineNode.offsetHeight;
28812881
}
28822882
}
2883-
const visibleLogicalLines = visibleEnd - visibleStart;
2883+
// scroll.getVisibleLineRange() returns an inclusive end index, so the
2884+
// number of visible logical lines is (end - start + 1), matching the
2885+
// iteration bounds used to sum totalPixelHeight above.
2886+
const visibleLogicalLines = visibleEnd - visibleStart + 1;
28842887
// Use pixel-based count: how many logical lines fit in one viewport
28852888
const numberOfLinesInViewport = visibleLogicalLines > 0 && totalPixelHeight > 0
28862889
? Math.max(1, Math.round(visibleLogicalLines * viewportHeight / totalPixelHeight))

0 commit comments

Comments
 (0)