float (@NotNull Editor editor) { return ReadAction.compute(() -> { Rectangle viewArea = editor.getScrollingModel().getVisibleAreaOnScrollingFinished(); if (viewArea.height == 0) { return 0f; } LogicalPosition pos = editor.getCaretModel().getLogicalPosition(); Point location = editor.logicalPositionToXY(pos); return (location.y - viewArea.y) / (float)viewArea.height; }); }