void (@NotNull final Editor editor, final int[] offsets) { Runnable processor = () -> { for (int offset : offsets) { final int line = editor.getDocument().getLineNumber(offset); FoldRegion region = FoldingUtil.findFoldRegionStartingAtLine(editor, line); if (region != null && !region.isExpanded()) { region.setExpanded(true); } else { FoldRegion[] regions = FoldingUtil.getFoldRegionsAtOffset(editor, offset); for (int i = regions.length - 1; i >= 0; i--) { region = regions[i]; if (!region.isExpanded()) { region.setExpanded(true); break; } } } } }; editor.getFoldingModel().runBatchFoldingOperation(processor); }