void (final EditorEx editor, Random random) { DocumentEx document = editor.getDocument(); if (document.isInBulkUpdate()) return; final FoldingModel foldingModel = editor.getFoldingModel(); FoldRegion[] foldRegions = foldingModel.getAllFoldRegions(); if (foldRegions.length == 0) return; final FoldRegion region = foldRegions[random.nextInt(foldRegions.length)]; foldingModel.runBatchFoldingOperation(() -> foldingModel.removeFoldRegion(region)); }