boolean (@NotNull Inlay inlay) { if (showWhenFolded(inlay)) { return false; } return ReadAction.compute(() -> { Editor editor = inlay.getEditor(); Inlay.Placement placement = inlay.getPlacement(); int offset = inlay.getOffset(); if (placement == Inlay.Placement.AFTER_LINE_END) { offset = DocumentUtil.getLineEndOffset(offset, editor.getDocument()); } else if ((placement == Inlay.Placement.ABOVE_LINE || placement == Inlay.Placement.BELOW_LINE) && !inlay.isRelatedToPrecedingText()) { offset--; } FoldingModel foldingModel = editor.getFoldingModel(); return foldingModel.isOffsetCollapsed(offset) || ((placement == Inlay.Placement.INLINE || placement == Inlay.Placement.AFTER_LINE_END) && foldingModel.getCollapsedRegionAtOffset(offset - 1) instanceof CustomFoldRegion); }); }