Commit fdc24639 authored by Thorbjørn Lindeijer's avatar Thorbjørn Lindeijer
Browse files

Relax the selection requirement for indent/unindent selection

Before, the selection was required to span multiple lines. Now, any
selection will trigger the line indenting functionality of
Tab/Shift+Tab. This should lead to less surprises.

Also, Shift+Tab will now always unindent the current line, even if there
is no selection, since there is nothing else sensible for this shortcut
to do.

Task-number: QTCREATORBUG-414
Reviewed-by: mae
parent 22d75c4c
......@@ -3243,11 +3243,10 @@ void BaseTextEditor::indentOrUnindent(bool doIndent)
int pos = cursor.position();
const TextEditor::TabSettings &tabSettings = d->m_document->tabSettings();
QTextDocument *doc = document();
if (!cursor.hasSelection()
|| (doc->findBlock(cursor.selectionStart()) == doc->findBlock(cursor.selectionEnd()) )) {
if (!cursor.hasSelection() && doIndent) {
// Insert tab if there is no selection and indent is requested
QTextBlock block = cursor.block();
QString text = block.text();
int indentPosition = (cursor.position() - block.position());;
......@@ -3260,6 +3259,7 @@ void BaseTextEditor::indentOrUnindent(bool doIndent)
cursor.insertText(tabSettings.indentationString(startColumn, targetColumn));
} else {
// Indent or unindent the selected lines
int anchor = cursor.anchor();
int start = qMin(anchor, pos);
int end = qMax(anchor, pos);
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