forked from qt-creator/qt-creator
make indenting the selection a single undo/redo command
This commit is contained in:
@@ -2751,7 +2751,9 @@ void BaseTextEditor::handleBackspaceKey()
|
|||||||
void BaseTextEditor::format()
|
void BaseTextEditor::format()
|
||||||
{
|
{
|
||||||
QTextCursor cursor = textCursor();
|
QTextCursor cursor = textCursor();
|
||||||
|
cursor.beginEditBlock();
|
||||||
indent(document(), cursor, QChar::Null);
|
indent(document(), cursor, QChar::Null);
|
||||||
|
cursor.endEditBlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseTextEditor::unCommentSelection()
|
void BaseTextEditor::unCommentSelection()
|
||||||
@@ -3319,16 +3321,13 @@ void BaseTextEditor::collapse()
|
|||||||
TextEditDocumentLayout *documentLayout = qobject_cast<TextEditDocumentLayout*>(doc->documentLayout());
|
TextEditDocumentLayout *documentLayout = qobject_cast<TextEditDocumentLayout*>(doc->documentLayout());
|
||||||
Q_ASSERT(documentLayout);
|
Q_ASSERT(documentLayout);
|
||||||
QTextBlock block = textCursor().block();
|
QTextBlock block = textCursor().block();
|
||||||
qDebug() << "collapse at block" << block.blockNumber();
|
|
||||||
while (block.isValid()) {
|
while (block.isValid()) {
|
||||||
qDebug() << "test block" << block.blockNumber();
|
|
||||||
if (TextBlockUserData::canCollapse(block) && block.next().isVisible()) {
|
if (TextBlockUserData::canCollapse(block) && block.next().isVisible()) {
|
||||||
if ((block.next().userState()) >> 8 <= (textCursor().block().userState() >> 8))
|
if ((block.next().userState()) >> 8 <= (textCursor().block().userState() >> 8))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
block = block.previous();
|
block = block.previous();
|
||||||
}
|
}
|
||||||
qDebug() << "found" << block.blockNumber();
|
|
||||||
if (block.isValid()) {
|
if (block.isValid()) {
|
||||||
TextBlockUserData::doCollapse(block, false);
|
TextBlockUserData::doCollapse(block, false);
|
||||||
d->moveCursorVisible();
|
d->moveCursorVisible();
|
||||||
|
|||||||
Reference in New Issue
Block a user