From 48a2e15c28447cebe0a5609aefe3c18ef64bf526 Mon Sep 17 00:00:00 2001
From: Orgad Shaneh <orgad.shaneh@audiocodes.com>
Date: Tue, 1 Dec 2015 13:57:22 +0200
Subject: [PATCH] TextEditor: Fix indentation of last line in selection

On normal selection it should *not* be indented.
On block selection it should.

Task-number: QTCREATORBUG-15300
Change-Id: I40ca1c24c6e14d05ca3c2d92a7562aac0eabb4c7
Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
---
 src/plugins/texteditor/textdocument.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/plugins/texteditor/textdocument.cpp b/src/plugins/texteditor/textdocument.cpp
index cc28f20dc5a..213f15cfccc 100644
--- a/src/plugins/texteditor/textdocument.cpp
+++ b/src/plugins/texteditor/textdocument.cpp
@@ -130,7 +130,7 @@ QTextCursor TextDocumentPrivate::indentOrUnindent(const QTextCursor &textCursor,
     bool modified = true;
 
     QTextBlock startBlock = m_document.findBlock(start);
-    QTextBlock endBlock = m_document.findBlock(end).next();
+    QTextBlock endBlock = m_document.findBlock(blockSelection ? end : end - 1).next();
 
     const bool oneLinePartial = (startBlock.next() == endBlock)
                               && (start > startBlock.position() || end < endBlock.position() - 1);
-- 
GitLab