forbid overlapping search results when highlighting

This commit is contained in:
mae
2009-12-02 13:31:17 +01:00
parent 54d3d06614
commit 89693f6347

View File

@@ -1875,11 +1875,12 @@ void BaseTextEditorPrivate::highlightSearchResults(const QTextBlock &block,
QString text = block.text(); QString text = block.text();
text.replace(QChar::Nbsp, QLatin1Char(' ')); text.replace(QChar::Nbsp, QLatin1Char(' '));
int idx = -1; int idx = -1;
int l = 1;
while (idx < text.length()) { while (idx < text.length()) {
idx = m_searchExpr.indexIn(text, idx + 1); idx = m_searchExpr.indexIn(text, idx + l);
if (idx < 0) if (idx < 0)
break; break;
int l = m_searchExpr.matchedLength(); l = m_searchExpr.matchedLength();
if ((m_findFlags & Find::IFindSupport::FindWholeWords) if ((m_findFlags & Find::IFindSupport::FindWholeWords)
&& ((idx && text.at(idx-1).isLetterOrNumber()) && ((idx && text.at(idx-1).isLetterOrNumber())
|| (idx + l < text.length() && text.at(idx + l).isLetterOrNumber()))) || (idx + l < text.length() && text.at(idx + l).isLetterOrNumber())))