void (EditorEx editor, SortedSet<? extends PreviewEditorFoldingRegion> foldingRegions) { editor.getFoldingModel().runBatchFoldingOperation(() -> { editor.getFoldingModel().clearFoldRegions(); editor.getMarkupModel().removeAllHighlighters(); for (PreviewEditorFoldingRegion region : foldingRegions) { if (region.getEndLine() - region.getStartLine() > 1) { FoldRegion currentRegion = FoldingModelSupport.addFolding(editor, region.getStartLine(), region.getEndLine(), false); if (currentRegion != null) { DiffDrawUtil.createLineSeparatorHighlighter(editor, editor.getDocument().getLineStartOffset(region.getStartLine()), editor.getDocument().getLineEndOffset(region.getEndLine() - 1), () -> currentRegion.isValid() && !currentRegion.isExpanded()); } } } }); }