diff options
author | Christian Kandeler <christian.kandeler@qt.io> | 2024-05-06 17:23:39 +0200 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@qt.io> | 2024-05-07 08:11:03 +0000 |
commit | bb2d565eccd27f3a6b2b8e09b6ac13b6ce477d6e (patch) | |
tree | 96a60945f9d41ffc077982e32d7c45932f165a84 /src/libs/utils/outputformatter.cpp | |
parent | 5e4281dafee8c1b4a0e1452b287d5e9d38bc30d4 (diff) |
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>
Diffstat (limited to 'src/libs/utils/outputformatter.cpp')
-rw-r--r-- | src/libs/utils/outputformatter.cpp | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/libs/utils/outputformatter.cpp b/src/libs/utils/outputformatter.cpp index f8b3d8cec7..a318bb1cca 100644 --- a/src/libs/utils/outputformatter.cpp +++ b/src/libs/utils/outputformatter.cpp @@ -402,23 +402,32 @@ const QList<FormattedText> OutputFormatter::linkifiedText( } for (int nextLocalTextPos = 0; nextLocalTextPos < t.text.size(); ) { - - // There are no more links in this part, so copy the rest of the text as-is. - if (nextLinkSpecIndex >= linkSpecs.size()) { + const auto copyRestOfSegmentAsIs = [&] { linkified << FormattedText(t.text.mid(nextLocalTextPos), t.format); totalTextLengthSoFar += t.text.length() - nextLocalTextPos; + }; + + // We are out of links. + if (nextLinkSpecIndex >= linkSpecs.size()) { + copyRestOfSegmentAsIs(); break; } const OutputLineParser::LinkSpec &linkSpec = linkSpecs.at(nextLinkSpecIndex); const int localLinkStartPos = linkSpec.startPos - totalPreviousTextLength; + + // There are more links, but not in this segment. + if (localLinkStartPos >= t.text.size()) { + copyRestOfSegmentAsIs(); + break; + } + ++nextLinkSpecIndex; // We ignore links that would cross format boundaries. if (localLinkStartPos < nextLocalTextPos || localLinkStartPos + linkSpec.length > t.text.length()) { - linkified << FormattedText(t.text.mid(nextLocalTextPos), t.format); - totalTextLengthSoFar += t.text.length() - nextLocalTextPos; + copyRestOfSegmentAsIs(); break; } |