forked from qt-creator/qt-creator
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>
This commit is contained in:
@@ -408,10 +408,14 @@ void OutputWindow::handleOutputChunk(const QString &output, OutputFormat format)
|
|||||||
{
|
{
|
||||||
QString out = output;
|
QString out = output;
|
||||||
if (out.size() > d->maxCharCount) {
|
if (out.size() > d->maxCharCount) {
|
||||||
// Current line alone exceeds limit, we need to cut it.
|
// Current chunk alone exceeds limit, we need to cut it.
|
||||||
out.truncate(d->maxCharCount);
|
const int elided = out.size() - d->maxCharCount;
|
||||||
out.append("[...]");
|
out = out.left(d->maxCharCount / 2)
|
||||||
setMaximumBlockCount(1);
|
+ "[[[... "
|
||||||
|
+ tr("Elided %1 characters due to Application Output settings").arg(elided)
|
||||||
|
+ " ...]]]"
|
||||||
|
+ out.right(d->maxCharCount / 2);
|
||||||
|
setMaximumBlockCount(out.count('\n') + 1);
|
||||||
} else {
|
} else {
|
||||||
int plannedChars = document()->characterCount() + out.size();
|
int plannedChars = document()->characterCount() + out.size();
|
||||||
if (plannedChars > d->maxCharCount) {
|
if (plannedChars > d->maxCharCount) {
|
||||||
|
Reference in New Issue
Block a user