adjustScroll method
Adjusts the scroll offset based on the viewport height.
Implementation
void adjustScroll(int viewportHeight) {
final lines = controller.value.lines;
if (lines.isEmpty || viewportHeight <= 0) return;
final currentCursorLine = cursorLine.clamp(0, lines.length - 1);
if (currentCursorLine < scrollOffset) {
scrollOffset = currentCursorLine;
} else if (currentCursorLine >= scrollOffset + viewportHeight) {
scrollOffset = currentCursorLine - viewportHeight + 1;
}
}