From 55dbc39ed01efdec6be8d3ad730dc923f922880c Mon Sep 17 00:00:00 2001
From: mae <qt-info@nokia.com>
Date: Mon, 9 Nov 2009 15:55:47 +0100
Subject: [PATCH] Fix auto-indentation when pasting into a selection

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

diff --git a/src/plugins/texteditor/basetexteditor.cpp b/src/plugins/texteditor/basetexteditor.cpp
index cd406907e03..2e1de346320 100644
--- a/src/plugins/texteditor/basetexteditor.cpp
+++ b/src/plugins/texteditor/basetexteditor.cpp
@@ -4654,6 +4654,7 @@ void BaseTextEditor::insertFromMimeData(const QMimeData *source)
     }
 
     cursor.beginEditBlock();
+    cursor.removeSelectedText();
 
     bool insertAtBeginningOfLine = ts.cursorIsAtBeginningOfLine(cursor);
 
@@ -4664,8 +4665,6 @@ void BaseTextEditor::insertFromMimeData(const QMimeData *source)
             return;
     }
 
-    cursor.removeSelectedText();
-
     int reindentBlockStart = cursor.blockNumber() + (insertAtBeginningOfLine?0:1);
 
     bool hasFinalNewline = (text.endsWith(QLatin1Char('\n'))
-- 
GitLab