int (int visualLine, int startOffset, int prevFoldRegionIndex) { if (visualLine < 0 || !hasBlockElements()) return 0; int visibleLineCount = myEditor.getVisibleLineCount(); if (visualLine >= visibleLineCount) { return myBlockElementsTree.getSumOfValuesUpToOffset(Integer.MAX_VALUE) - myEditor.getFoldingModel().getTotalHeightOfFoldedBlockInlays(); } int[] result = {0}; int endOffset = visualLine >= visibleLineCount - 1 ? myEditor.getDocument().getTextLength() : myEditor.visualLineStartOffset(visualLine + 1) - 1; if (visualLine > 0) { result[0] += myBlockElementsTree.getSumOfValuesUpToOffset(startOffset - 1) - myEditor.getFoldingModel().getHeightOfFoldedBlockInlaysBefore(prevFoldRegionIndex); } myBlockElementsTree.processOverlappingWith(startOffset, endOffset, inlay -> { if (inlay.myShowAbove && !EditorUtil.isInlayFolded(inlay)) { result[0] += inlay.getHeightInPixels(); } return true; }); return result[0]; }