Skip to content

Commit

Permalink
Fix favorite highlighting for tags with special chars (fix #2759)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bionus committed Jul 19, 2022
1 parent ffdd52f commit aae0398
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/lib/src/search-syntax-highlighter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,26 @@ SearchSyntaxHighlighter::SearchSyntaxHighlighter(bool full, QTextDocument *paren

void SearchSyntaxHighlighter::updateFavorites()
{
QString favorites;
QString merged;
for (const auto &favorite : m_profile->getFavorites()) {
if (!favorites.isEmpty()) {
favorites += '|';
if (!merged.isEmpty()) {
merged += '|';
}
favorites += favorite.getName();
merged += QRegularExpression::escape(favorite.getName());
}
m_favoritesRule->pattern.setPattern("(?: |^)(" + favorites + ")(?: |$)");
m_favoritesRule->pattern.setPattern("(?: |^)(" + merged + ")(?: |$)");
}

void SearchSyntaxHighlighter::updateKeptForLater()
{
m_kflRule->pattern.setPattern("(?: |^)(" + m_profile->getKeptForLater().join('|') + ")(?: |$)");
QString merged;
for (const auto &kfl : m_profile->getKeptForLater()) {
if (!merged.isEmpty()) {
merged += '|';
}
merged += QRegularExpression::escape(kfl);
}
m_kflRule->pattern.setPattern("(?: |^)(" + merged + ")(?: |$)");
}

void SearchSyntaxHighlighter::highlightBlock(const QString &text)
Expand Down

0 comments on commit aae0398

Please sign in to comment.