void (@NotNull Editor editor, float proportion) { ReadAction.run(() -> { Rectangle viewArea = editor.getScrollingModel().getVisibleArea(); LogicalPosition caretPosition = editor.getCaretModel().getLogicalPosition(); Point caretLocation = editor.logicalPositionToXY(caretPosition); int yPos = caretLocation.y; yPos -= viewArea.height * proportion; editor.getScrollingModel().scrollVertically(yPos); }); }