From 536dd779fca8503864bc64ffb8af74993a9af5d2 Mon Sep 17 00:00:00 2001 From: hjk Date: Fri, 17 Jul 2020 07:32:29 +0200 Subject: [PATCH] Core: Improve handling of long output chunks Single chunks exceeding the limit were truncated and then shown in a single line, potentially resulting in only a few chars if there was a newline close to the cut-off point. Now, don't restrict to a single line in that csae. Additionally elide in the middle, assuming this is a better compromise than truncating at either end. Also, make the truncation more obvious, and mention the amount of elided characters. Change-Id: I850e2833e7f1f8be0f584d8e4439dd1a64f851d0 Reviewed-by: Christian Kandeler --- src/plugins/coreplugin/outputwindow.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/plugins/coreplugin/outputwindow.cpp b/src/plugins/coreplugin/outputwindow.cpp index 7c05ee6630f..fb5df625111 100644 --- a/src/plugins/coreplugin/outputwindow.cpp +++ b/src/plugins/coreplugin/outputwindow.cpp @@ -408,10 +408,14 @@ void OutputWindow::handleOutputChunk(const QString &output, OutputFormat format) { QString out = output; if (out.size() > d->maxCharCount) { - // Current line alone exceeds limit, we need to cut it. - out.truncate(d->maxCharCount); - out.append("[...]"); - setMaximumBlockCount(1); + // Current chunk alone exceeds limit, we need to cut it. + const int elided = out.size() - d->maxCharCount; + out = out.left(d->maxCharCount / 2) + + "[[[... " + + tr("Elided %1 characters due to Application Output settings").arg(elided) + + " ...]]]" + + out.right(d->maxCharCount / 2); + setMaximumBlockCount(out.count('\n') + 1); } else { int plannedChars = document()->characterCount() + out.size(); if (plannedChars > d->maxCharCount) {