int (@NotNull Editor editor) { return ReadAction.compute(() -> { int caretY = editor.visualLineToY(editor.getCaretModel().getVisualPosition().line); int viewAreaPosition = editor.getScrollingModel().getVisibleAreaOnScrollingFinished().y; return caretY - viewAreaPosition; }); }