Editor: Fix indenting on the very first position of a document

Task-number: QTCREATORBUG-19294
Change-Id: I3c859d90f0c58165d526b2c9dd9a7afe2abda94b
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
David Schulz
2017-11-14 15:31:59 +01:00
parent dbe7ea7d88
commit 63d18a4537

View File

@@ -128,7 +128,7 @@ QTextCursor TextDocumentPrivate::indentOrUnindent(const QTextCursor &textCursor,
bool modified = true; bool modified = true;
QTextBlock startBlock = m_document.findBlock(start); QTextBlock startBlock = m_document.findBlock(start);
QTextBlock endBlock = m_document.findBlock(blockSelection ? end : end - 1).next(); QTextBlock endBlock = m_document.findBlock(blockSelection ? end : qMax(end - 1, 0)).next();
const bool cursorAtBlockStart = (textCursor.position() == startBlock.position()); const bool cursorAtBlockStart = (textCursor.position() == startBlock.position());
const bool anchorAtBlockStart = (textCursor.anchor() == startBlock.position()); const bool anchorAtBlockStart = (textCursor.anchor() == startBlock.position());
const bool oneLinePartial = (startBlock.next() == endBlock) const bool oneLinePartial = (startBlock.next() == endBlock)