aboutsummaryrefslogtreecommitdiffstats
path: root/src/libs/utils/outputformatter.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/libs/utils/outputformatter.cpp')
-rw-r--r--src/libs/utils/outputformatter.cpp19
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;
}