diff --git a/src/plugins/texteditor/basetexteditor.cpp b/src/plugins/texteditor/basetexteditor.cpp index 16194911f0e..af61f7275b2 100644 --- a/src/plugins/texteditor/basetexteditor.cpp +++ b/src/plugins/texteditor/basetexteditor.cpp @@ -4363,7 +4363,9 @@ void BaseTextEditorWidget::indentOrUnindent(bool doIndent) QTextBlock startBlock = doc->findBlock(start); QTextBlock endBlock = doc->findBlock(end-1).next(); - if (startBlock.next() == endBlock) { // Only one line selected + if (startBlock.next() == endBlock + && (start > startBlock.position() || end < endBlock.position() - 1)) { + // Only one line partially selected. cursor.removeSelectedText(); } else { for (QTextBlock block = startBlock; block != endBlock; block = block.next()) {