forked from qt-creator/qt-creator
Utils: Fix output linkification
The case where links are combined with other formatting was not correctly implemented. Fixes: QTCREATORBUG-30774 Change-Id: Ie56a7f4c9a1f8a9b23848cc6fd4b7749bb6cecd7 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -402,23 +402,32 @@ const QList<FormattedText> OutputFormatter::linkifiedText(
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (int nextLocalTextPos = 0; nextLocalTextPos < t.text.size(); ) {
|
for (int nextLocalTextPos = 0; nextLocalTextPos < t.text.size(); ) {
|
||||||
|
const auto copyRestOfSegmentAsIs = [&] {
|
||||||
// There are no more links in this part, so copy the rest of the text as-is.
|
|
||||||
if (nextLinkSpecIndex >= linkSpecs.size()) {
|
|
||||||
linkified << FormattedText(t.text.mid(nextLocalTextPos), t.format);
|
linkified << FormattedText(t.text.mid(nextLocalTextPos), t.format);
|
||||||
totalTextLengthSoFar += t.text.length() - nextLocalTextPos;
|
totalTextLengthSoFar += t.text.length() - nextLocalTextPos;
|
||||||
|
};
|
||||||
|
|
||||||
|
// We are out of links.
|
||||||
|
if (nextLinkSpecIndex >= linkSpecs.size()) {
|
||||||
|
copyRestOfSegmentAsIs();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
const OutputLineParser::LinkSpec &linkSpec = linkSpecs.at(nextLinkSpecIndex);
|
const OutputLineParser::LinkSpec &linkSpec = linkSpecs.at(nextLinkSpecIndex);
|
||||||
const int localLinkStartPos = linkSpec.startPos - totalPreviousTextLength;
|
const int localLinkStartPos = linkSpec.startPos - totalPreviousTextLength;
|
||||||
|
|
||||||
|
// There are more links, but not in this segment.
|
||||||
|
if (localLinkStartPos >= t.text.size()) {
|
||||||
|
copyRestOfSegmentAsIs();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
++nextLinkSpecIndex;
|
++nextLinkSpecIndex;
|
||||||
|
|
||||||
// We ignore links that would cross format boundaries.
|
// We ignore links that would cross format boundaries.
|
||||||
if (localLinkStartPos < nextLocalTextPos
|
if (localLinkStartPos < nextLocalTextPos
|
||||||
|| localLinkStartPos + linkSpec.length > t.text.length()) {
|
|| localLinkStartPos + linkSpec.length > t.text.length()) {
|
||||||
linkified << FormattedText(t.text.mid(nextLocalTextPos), t.format);
|
copyRestOfSegmentAsIs();
|
||||||
totalTextLengthSoFar += t.text.length() - nextLocalTextPos;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user