forked from qt-creator/qt-creator
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> becomes 1. #include <QDebug> 2.| 3. #include <QTest> after Ctrl+Shift+Enter. When the cursor is on the first line, however: 1.|#include <QDebug> 2. #include <QTest> becomes 1. #include <QDebug> 2.| 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: David Schulz <david.schulz@digia.com>
This commit is contained in:
committed by
David Schulz
parent
271fb797cb
commit
e237057827
@@ -1015,9 +1015,11 @@ void BaseTextEditorWidget::insertLineAbove()
|
||||
{
|
||||
QTextCursor cursor = textCursor();
|
||||
cursor.beginEditBlock();
|
||||
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.insertBlock();
|
||||
cursor.movePosition(QTextCursor::PreviousBlock, QTextCursor::MoveAnchor);
|
||||
indent(document(), cursor, QChar::Null);
|
||||
cursor.endEditBlock();
|
||||
setTextCursor(cursor);
|
||||
|
||||
Reference in New Issue
Block a user