void (@NotNull List<Pair<String, Key>> lineChunks) { int totalLength = 0; for (Pair<String, Key> chunk : lineChunks) { totalLength += chunk.first.length(); } int prefixEnd = (int)(MAX_CONSOLE_OUTPUT_SIZE * 0.3); int suffixStart = totalLength - (int)(MAX_CONSOLE_OUTPUT_SIZE * 0.7); boolean useEllipsis = totalLength > MAX_CONSOLE_OUTPUT_SIZE * 1.2; int index = 0; List<Pair<String, ConsoleViewContentType>> messages = new ArrayList<>(); for (Pair<String, Key> chunk : lineChunks) { String message = chunk.first; if (message.isEmpty()) continue; ConsoleViewContentType type = ConsoleViewContentType.getConsoleViewType(chunk.second); if (useEllipsis) { TextRange range = new TextRange(index, index + message.length()); TextRange range1 = range.intersection(new TextRange(0, prefixEnd)); TextRange range2 = range.intersection(new TextRange(suffixStart, totalLength)); if (range1 != null && !range1.isEmpty()) { String message1 = range1.shiftLeft(index).substring(message); if (!range1.equals(range)) message1 += "..."; // add ellipsis to the last chunk before the cut messages.add(Pair.create(message1, type)); } if (range2 != null && !range2.isEmpty()) { String message2 = range2.shiftLeft(index).substring(message); messages.add(Pair.create(message2, type)); } } else { messages.add(Pair.create(message, type)); } index += message.length(); } showMessage(VcsConsoleLine.create(messages)); }