diff --git a/src/plugins/texteditor/basetexteditor.cpp b/src/plugins/texteditor/basetexteditor.cpp
index 3f2d1ef98502861445df520fd2d075e6330688f7..55f6a2459f83eece8d64daa99f9f40c4e8e41ce3 100644
--- a/src/plugins/texteditor/basetexteditor.cpp
+++ b/src/plugins/texteditor/basetexteditor.cpp
@@ -2092,10 +2092,12 @@ void BaseTextEditor::paintEvent(QPaintEvent *e)
     QAbstractTextDocumentLayout::PaintContext context = getPaintContext();
 
     if (!d->m_findScope.isNull()) {
-        QAbstractTextDocumentLayout::Selection selection;
-        selection.format.setBackground(d->m_searchScopeFormat.background());
-        selection.cursor = d->m_findScope;
-        context.selections.prepend(selection);
+
+        TextEditorOverlay *overlay = new TextEditorOverlay(this);
+        overlay->addOverlaySelection(d->m_findScope, d->m_searchScopeFormat.background().color().darker(120),
+                                     d->m_searchScopeFormat.background().color());
+        overlay->paint(&painter, e->rect());
+        delete overlay;
     }
 
     BlockSelectionData *blockSelection = 0;
@@ -2146,6 +2148,7 @@ void BaseTextEditor::paintEvent(QPaintEvent *e)
 
     } // end first pass
 
+
     d->m_searchResultOverlay->fill(&painter,
                                    d->m_searchResultFormat.background().color(),
                                    e->rect());
@@ -2978,13 +2981,25 @@ void BaseTextEditor::slotUpdateBlockNotify(const QTextBlock &block)
         /* an overlay might draw outside the block bounderies, force
            complete viewport update */
         viewport()->update();
-    } else if (block.previous().isValid() && block.userState() != block.previous().userState()) {
+    } else {
+        if (block.previous().isValid() && block.userState() != block.previous().userState()) {
         /* The syntax highlighting state changes. This opens up for
            the possibility that the paragraph has braces that support
            code folding. In this case, do the save thing and also
            update the previous block, which might contain a collapse
            box which now is invalid.*/
-        emit requestBlockUpdate(block.previous());
+            emit requestBlockUpdate(block.previous());
+        }
+        if (!d->m_findScope.isNull()) {
+            if (block.position() < d->m_findScope.selectionEnd()
+                && block.position()+block.length() >= d->m_findScope.selectionStart() ) {
+                QTextBlock b = block.document()->findBlock(d->m_findScope.selectionStart());
+                do {
+                    emit requestBlockUpdate(b);
+                    b = b.next();
+                } while (b.isValid() && b.position() < d->m_findScope.selectionEnd());
+            }
+        }
     }
     blockRecursion = false;
 }
diff --git a/src/plugins/texteditor/texteditoroverlay.cpp b/src/plugins/texteditor/texteditoroverlay.cpp
index e2ea55a4cc1e54890b4a5c9406e987a6c613b7f5..183db1140d22263a561629e4dd107525f1575571 100644
--- a/src/plugins/texteditor/texteditoroverlay.cpp
+++ b/src/plugins/texteditor/texteditoroverlay.cpp
@@ -308,6 +308,18 @@ void TextEditorOverlay::paintSelection(QPainter *painter,
     }
 
     painter->setRenderHint(QPainter::Antialiasing);
+
+    if (selection.m_dropShadow) {
+        painter->save();
+        painter->translate(m_dropShadowWidth, m_dropShadowWidth);
+
+        QPainterPath clip = path;
+        clip.translate(-m_dropShadowWidth, -m_dropShadowWidth);
+        painter->setClipPath(clip.intersected(path));
+        painter->fillPath(path, QColor(0, 0, 0, 100));
+        painter->restore();
+    }
+
     pen.setJoinStyle(Qt::RoundJoin);
     painter->setPen(pen);
     painter->drawPath(path);
@@ -328,11 +340,6 @@ void TextEditorOverlay::fillSelection(QPainter *painter,
     painter->save();
     painter->translate(-.5, -.5);
     painter->setRenderHint(QPainter::Antialiasing);
-    if (selection.m_dropShadow) {
-        painter->translate(m_dropShadowWidth, m_dropShadowWidth);
-        painter->fillPath(path, QColor(0, 0, 0, 100));
-        painter->translate(-m_dropShadowWidth, -m_dropShadowWidth);
-    }
     painter->fillPath(path, color);
     painter->restore();
 }