void (@Nullable ExecutionConsole consoleView, String text, boolean isGreeting) { int limit = 100; if (text.length() < limit) { return; } final ConsoleViewImpl consoleViewImpl; if (consoleView instanceof ConsoleViewImpl) { consoleViewImpl = (ConsoleViewImpl)consoleView; } else if (consoleView instanceof DuplexConsoleView duplexConsoleView) { if (duplexConsoleView.getPrimaryConsoleView() instanceof ConsoleViewImpl) { consoleViewImpl = (ConsoleViewImpl)duplexConsoleView.getPrimaryConsoleView(); } else if (duplexConsoleView.getSecondaryConsoleView() instanceof ConsoleViewImpl) { consoleViewImpl = (ConsoleViewImpl)duplexConsoleView.getSecondaryConsoleView(); } else { consoleViewImpl = null; } } else { consoleViewImpl = null; } if (consoleViewImpl != null) { UIUtil.invokeLaterIfNeeded(() -> { consoleViewImpl.performWhenNoDeferredOutput(() -> { if (!ApplicationManager.getApplication().isDispatchThread()) return; Document document = consoleViewImpl.getEditor().getDocument(); int line = isGreeting ? 0 : document.getLineCount() - 2; if (CharArrayUtil.regionMatches(document.getCharsSequence(), document.getLineStartOffset(line), text)) { final FoldingModel foldingModel = consoleViewImpl.getEditor().getFoldingModel(); foldingModel.runBatchFoldingOperation(() -> { FoldRegion region = foldingModel.addFoldRegion(document.getLineStartOffset(line), document.getLineEndOffset(line) + 1, StringUtil.trimLog(text, limit)); if (region != null) { region.setExpanded(false); } }); } }); }); } }