forked from qt-creator/qt-creator
TextEditor: Fixed indentation in block selection mode
Made indentation work for block selection mode the same way it does in default mode: 1. delete text if any selected 2. indent block if no text selected 3. indent last line if cursor in first column (QTCREATORBUG-12697) Task-number: QTCREATORBUG-12697 Change-Id: I1f6b218b389f3fdc5232ec02857aa76f5ccbaaf0 Reviewed-by: André Hartmann <aha_1980@gmx.de> Reviewed-by: David Schulz <david.schulz@theqtcompany.com>
This commit is contained in:
committed by
David Schulz
parent
c5bca90b0e
commit
aab3b0fc66
@@ -1495,12 +1495,26 @@ void TextEditorWidget::lowercaseSelection()
|
||||
|
||||
void TextEditorWidget::indent()
|
||||
{
|
||||
setTextCursor(textDocument()->indent(textCursor()));
|
||||
int offset = 0;
|
||||
doSetTextCursor(textDocument()->indent(textCursor(), d->m_inBlockSelectionMode,
|
||||
d->m_blockSelection.positionColumn, &offset),
|
||||
d->m_inBlockSelectionMode);
|
||||
if (d->m_inBlockSelectionMode) {
|
||||
d->m_blockSelection.anchorColumn += offset;
|
||||
d->m_blockSelection.positionColumn += offset;
|
||||
}
|
||||
}
|
||||
|
||||
void TextEditorWidget::unindent()
|
||||
{
|
||||
setTextCursor(textDocument()->unindent(textCursor()));
|
||||
int offset = 0;
|
||||
doSetTextCursor(textDocument()->unindent(textCursor(), d->m_inBlockSelectionMode,
|
||||
d->m_blockSelection.positionColumn, &offset),
|
||||
d->m_inBlockSelectionMode);
|
||||
if (d->m_inBlockSelectionMode) {
|
||||
d->m_blockSelection.anchorColumn += offset;
|
||||
d->m_blockSelection.positionColumn += offset;
|
||||
}
|
||||
}
|
||||
|
||||
void TextEditorWidget::undo()
|
||||
@@ -2254,10 +2268,15 @@ void TextEditorWidget::keyPressEvent(QKeyEvent *e)
|
||||
}
|
||||
d->m_document->autoIndent(cursor);
|
||||
} else {
|
||||
if (e->key() == Qt::Key_Tab)
|
||||
indent();
|
||||
else
|
||||
unindent();
|
||||
if (d->m_inBlockSelectionMode
|
||||
&& d->m_blockSelection.firstVisualColumn() != d->m_blockSelection.lastVisualColumn()) {
|
||||
d->removeBlockSelection();
|
||||
} else {
|
||||
if (e->key() == Qt::Key_Tab)
|
||||
indent();
|
||||
else
|
||||
unindent();
|
||||
}
|
||||
}
|
||||
e->accept();
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user