@@ -107,9 +107,8 @@ QString FormattedString::Part::toHtml(QStringView fullText, const ColorTheme& th
107107 }
108108
109109 QString finalText;
110- const auto urlThreshold = Lith::settingsGet ()->shortenLongUrlsThresholdGet ();
111- const auto urlShortenEnabled = Lith::settingsGet ()->shortenLongUrlsGet ();
112- if (urlThreshold > 0 && hyperlink && n > urlThreshold && urlShortenEnabled) {
110+ const auto urlThreshold = trim;
111+ if (urlThreshold > 0 && hyperlink && n > urlThreshold) {
113112 auto url = QUrl (text (fullText, -1 ).toString ());
114113 auto scheme = url.scheme ();
115114 auto host = url.host ();
@@ -123,7 +122,7 @@ QString FormattedString::Part::toHtml(QStringView fullText, const ColorTheme& th
123122 } else {
124123 // We'll show always show the host and the scheme.
125124 const auto hostPrefix = scheme + QStringLiteral (" ://" ) + host + QStringLiteral (" /" );
126- constexpr auto ellipsis = QLatin1String (" \u2026 " );
125+ const auto ellipsis = QStringLiteral (" \u2026 " );
127126
128127 // The threshold is so small that it doesn't even accomodate the hostPrefix. We'll just put the hostPrefix and
129128 // ellipsis...
@@ -143,7 +142,7 @@ QString FormattedString::Part::toHtml(QStringView fullText, const ColorTheme& th
143142 }
144143 }
145144 } else {
146- finalText = text (fullText, trim ).toString ();
145+ finalText = text (fullText, - 1 ).toString ();
147146 }
148147 ret.append (finalText.toHtmlEscaped ());
149148
@@ -212,6 +211,7 @@ FormattedString::Part& FormattedString::addPart(QStringView s) {
212211 auto & newPart = addPart ();
213212 newPart.pos = m_fullText.size ();
214213 newPart.n = s.size ();
214+ m_fullText += s;
215215 return newPart;
216216}
217217
@@ -321,15 +321,17 @@ void FormattedString::prune() {
321321 int previousEnd = 0 ;
322322 while (reIt.hasNext ()) {
323323 auto reMatch = reIt.next ();
324- Part prefix {previousEnd, reMatch.capturedStart () - previousEnd};
325- Part url = Part {reMatch.capturedStart (), reMatch.capturedLength ()};
324+ Part prefix {it-> pos + previousEnd, reMatch.capturedStart () - previousEnd};
325+ Part url = Part {it-> pos + reMatch.capturedStart (), reMatch.capturedLength ()};
326326 url.hyperlink = true ;
327- segments.emplace_back (std::move (prefix));
327+ if (prefix.n > 0 ) {
328+ segments.emplace_back (std::move (prefix));
329+ }
328330 segments.emplace_back (std::move (url));
329331 previousEnd = static_cast <int >(reMatch.capturedEnd ());
330332 }
331333 if (previousEnd < it->n ) {
332- Part suffix = Part {previousEnd, it->n - previousEnd};
334+ Part suffix = Part {it-> pos + previousEnd, it->n - previousEnd};
333335 segments.emplace_back (std::move (suffix));
334336 }
335337 it = m_parts.erase (it);
0 commit comments