diff --git a/src/plugins/debugger/qml/qmljsscriptconsole.cpp b/src/plugins/debugger/qml/qmljsscriptconsole.cpp
index e83ac29617ae2f44018a6dad82dee0c47784c15b..1626f33619df70f6fb50710cc7e1d90322c76ec0 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()