forked from qt-creator/qt-creator
ClangFormat: Introduce check to format code instead of indenting
Ctrl+I with the new check will reformat the selected code or the current line instead. Change-Id: Ia5a72c4a09621034d0dfe463f669fe1ca36b0b5f Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io> Reviewed-by: Marco Bubke <marco.bubke@qt.io>
This commit is contained in:
@@ -7135,21 +7135,11 @@ void TextEditorWidget::setIfdefedOutBlocks(const QList<BlockRange> &blocks)
|
||||
documentLayout->requestUpdate();
|
||||
}
|
||||
|
||||
static bool applyFormattingInsteadOfIndentation()
|
||||
{
|
||||
constexpr const char option[] = "QTC_FORMAT_INSTEAD_OF_INDENT";
|
||||
return qEnvironmentVariableIsSet(option);
|
||||
}
|
||||
|
||||
void TextEditorWidget::format()
|
||||
{
|
||||
static bool formattingInsteadOfIndentation = applyFormattingInsteadOfIndentation();
|
||||
QTextCursor cursor = textCursor();
|
||||
cursor.beginEditBlock();
|
||||
if (formattingInsteadOfIndentation)
|
||||
d->m_document->autoFormat(cursor);
|
||||
else
|
||||
d->m_document->autoIndent(cursor);
|
||||
d->m_document->autoFormatOrIndent(cursor);
|
||||
cursor.endEditBlock();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user