From d919af68a570f30d992fa927e9c07b92ca55675f Mon Sep 17 00:00:00 2001 From: Bill Somerville Date: Fri, 5 Jun 2020 17:55:45 +0100 Subject: [PATCH] Repair UDP Highlight Callsign regression When passing the 'Highlight last' parameter as true occasional matches in prior periods could be incorrectly highlighted. This fix should also improve performance when there is a large decode history, and highlight request for a new callsign is received. --- widgets/displaytext.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/widgets/displaytext.cpp b/widgets/displaytext.cpp index ef91761fc..f0f17f648 100644 --- a/widgets/displaytext.cpp +++ b/widgets/displaytext.cpp @@ -13,7 +13,6 @@ #include #include #include -#include #include "Configuration.hpp" #include "Network/LotWUsers.hpp" @@ -126,8 +125,6 @@ namespace void DisplayText::appendText(QString const& text, QColor bg, QColor fg , QString const& call1, QString const& call2) { -// qDebug () << "DisplayText::appendText: text:" << text << "Nbsp pos:" << text.indexOf (QChar::Nbsp); - auto cursor = textCursor (); cursor.movePosition (QTextCursor::End); auto block_format = cursor.blockFormat (); @@ -548,7 +545,6 @@ namespace void DisplayText::highlight_callsign (QString const& callsign, QColor const& bg, QColor const& fg, bool last_period_only) { - // qDebug () << "DisplayText::highlight_callsign: callsign:" << callsign << "last period:" << last_period_only; if (!callsign.size ()) { return; @@ -575,10 +571,10 @@ void DisplayText::highlight_callsign (QString const& callsign, QColor const& bg, { period_start = prior; } - while (!cursor.isNull () && cursor > period_start) + cursor = period_start; + while (!cursor.isNull ()) { - cursor = document ()->find (target, cursor - , QTextDocument::FindBackward | QTextDocument::FindWholeWords); + cursor = document ()->find (target, cursor, QTextDocument::FindWholeWords); if (!cursor.isNull () && cursor.hasSelection ()) { if (bg.isValid () || fg.isValid ())