From 89693f63470622c7ddcc6db9db75b714a93db5e6 Mon Sep 17 00:00:00 2001
From: mae <qt-info@nokia.com>
Date: Wed, 2 Dec 2009 13:31:17 +0100
Subject: [PATCH] forbid overlapping search results when highlighting

---
 src/plugins/texteditor/basetexteditor.cpp | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/plugins/texteditor/basetexteditor.cpp b/src/plugins/texteditor/basetexteditor.cpp
index 55f6a2459f8..0ee70102db2 100644
--- a/src/plugins/texteditor/basetexteditor.cpp
+++ b/src/plugins/texteditor/basetexteditor.cpp
@@ -1875,11 +1875,12 @@ void BaseTextEditorPrivate::highlightSearchResults(const QTextBlock &block,
     QString text = block.text();
     text.replace(QChar::Nbsp, QLatin1Char(' '));
     int idx = -1;
+    int l = 1;
     while (idx < text.length()) {
-        idx = m_searchExpr.indexIn(text, idx + 1);
+        idx = m_searchExpr.indexIn(text, idx + l);
         if (idx < 0)
             break;
-        int l = m_searchExpr.matchedLength();
+        l = m_searchExpr.matchedLength();
         if ((m_findFlags & Find::IFindSupport::FindWholeWords)
             && ((idx && text.at(idx-1).isLetterOrNumber())
                 || (idx + l < text.length() && text.at(idx + l).isLetterOrNumber())))
-- 
GitLab