summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorhjk <hjk@qt.io>2020-07-17 07:32:29 +0200
committerhjk <hjk@qt.io>2020-07-17 12:44:41 +0000
commit536dd779fca8503864bc64ffb8af74993a9af5d2 (patch)
tree8831c9c7fbd9f518944da75ef0d03859c6d7b171 /src
parent4db32606e0ef0d7d9ff88a8898fe30608fea144f (diff)
downloadqt-creator-536dd779fca8503864bc64ffb8af74993a9af5d2.tar.gz
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 <christian.kandeler@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/coreplugin/outputwindow.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/plugins/coreplugin/outputwindow.cpp b/src/plugins/coreplugin/outputwindow.cpp
index 7c05ee6630..fb5df62511 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) {