LineRange (Editor editor) { return ReadAction.compute(() -> { Rectangle area = editor.getScrollingModel().getVisibleArea(); if (area.height < 0) return new LineRange(0, 0); LogicalPosition position1 = editor.xyToLogicalPosition(new Point(0, area.y)); LogicalPosition position2 = editor.xyToLogicalPosition(new Point(0, area.y + area.height)); return new LineRange(position1.line, position2.line); }); }