From 2bc5c81a5a0915731bba60495c8a404cb6a0a025 Mon Sep 17 00:00:00 2001
From: Aurindam Jana <aurindam.jana@nokia.com>
Date: Tue, 10 Jan 2012 16:51:24 +0100
Subject: [PATCH] ScriptConsole: Refactor extra selections code

Change-Id: I251dc5646bfcf1da386939bb8309b8db6cd2eeaa
Reviewed-by: Kai Koehne <kai.koehne@nokia.com>
---
 src/plugins/debugger/qml/qmljsscriptconsole.cpp | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/src/plugins/debugger/qml/qmljsscriptconsole.cpp b/src/plugins/debugger/qml/qmljsscriptconsole.cpp
index e83ac29617a..1626f33619d 100644
--- a/src/plugins/debugger/qml/qmljsscriptconsole.cpp
+++ b/src/plugins/debugger/qml/qmljsscriptconsole.cpp
@@ -222,27 +222,21 @@ void QmlJSScriptConsole::appendResult(const QString &result)
     QTextCursor cur = textCursor();
     cur.movePosition(QTextCursor::End);
     cur.insertText(_("\n"));
+
     cur.insertText(result);
-    cur.movePosition(QTextCursor::EndOfLine);
     cur.insertText(_("\n"));
-    setTextCursor(cur);
-    displayPrompt();
 
     QTextEdit::ExtraSelection sel;
-
     QTextCharFormat resultFormat;
     resultFormat.setForeground(QBrush(QColor(Qt::darkGray)));
-
-    QTextCursor c(document()->findBlockByNumber(cur.blockNumber()-1));
-    c.movePosition(QTextCursor::StartOfBlock);
-    c.movePosition(QTextCursor::NextBlock, QTextCursor::KeepAnchor);
-
+    cur.movePosition(QTextCursor::PreviousBlock);
+    cur.movePosition(QTextCursor::EndOfBlock, QTextCursor::KeepAnchor);
     sel.format = resultFormat;
-    sel.cursor = c;
-
+    sel.cursor = cur;
     d->selections.append(sel);
 
     setExtraSelections(d->selections);
+    displayPrompt();
 }
 
 void QmlJSScriptConsole::clear()
-- 
GitLab