Commit e2370578 authored by Mitch Curtis's avatar Mitch Curtis Committed by David Schulz

Make insertLineAbove behaviour consistent when at top of document.

Currently, pressing Ctrl+Shift+Enter to insert a line above the current
line does not work consistently when the current line is the first in
the document. For example, if the cursor (|) is not on the first line:

1. #include <QDebug>
2.|#include <QTest>


1. #include <QDebug>
3. #include <QTest>

after Ctrl+Shift+Enter. When the cursor is on the first line, however:

1.|#include <QDebug>
2. #include <QTest>


1. #include <QDebug>
3. #include <QTest>

after Ctrl+Shift+Enter. This patch corrects the above result:

1. |
2. #include <QDebug>
3. #include <QTest>

This is also in line with Eclipse's behaviour, for example.

Change-Id: I542050b6090ed0cfdf613bf67bbd2651eb99ec9d
Reviewed-by: default avatarDavid Schulz <>
parent 271fb797
......@@ -1015,9 +1015,11 @@ void BaseTextEditorWidget::insertLineAbove()
QTextCursor cursor = textCursor();
cursor.movePosition(QTextCursor::PreviousBlock, QTextCursor::MoveAnchor);
cursor.movePosition(QTextCursor::EndOfBlock, QTextCursor::MoveAnchor);
// If the cursor is at the beginning of the document,
// it should still insert a line above the current line.
cursor.movePosition(QTextCursor::StartOfBlock, QTextCursor::MoveAnchor);
cursor.movePosition(QTextCursor::PreviousBlock, QTextCursor::MoveAnchor);
indent(document(), cursor, QChar::Null);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment