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:
@@ -317,8 +317,7 @@ void ClangFormatBaseIndenter::reindent(const QTextCursor &cursor,
|
||||
indent(cursor, QChar::Null);
|
||||
}
|
||||
|
||||
TextEditor::Replacements ClangFormatBaseIndenter::format(
|
||||
const QTextCursor &cursor, const TextEditor::TabSettings & /*tabSettings*/)
|
||||
TextEditor::Replacements ClangFormatBaseIndenter::format(const QTextCursor &cursor)
|
||||
{
|
||||
int utf8Offset;
|
||||
int utf8Length;
|
||||
@@ -345,6 +344,12 @@ TextEditor::Replacements ClangFormatBaseIndenter::format(
|
||||
return toReplace;
|
||||
}
|
||||
|
||||
TextEditor::Replacements ClangFormatBaseIndenter::format(
|
||||
const QTextCursor &cursor, const TextEditor::TabSettings & /*tabSettings*/)
|
||||
{
|
||||
return format(cursor);
|
||||
}
|
||||
|
||||
void ClangFormatBaseIndenter::indentBlock(const QTextBlock &block, const QChar &typedChar)
|
||||
{
|
||||
trimFirstNonEmptyBlock(block);
|
||||
@@ -405,6 +410,16 @@ bool ClangFormatBaseIndenter::isElectricCharacter(const QChar &ch) const
|
||||
return false;
|
||||
}
|
||||
|
||||
void ClangFormatBaseIndenter::formatOrIndent(const QTextCursor &cursor,
|
||||
const TextEditor::TabSettings & /*tabSettings*/,
|
||||
int /*cursorPositionInEditor*/)
|
||||
{
|
||||
if (formatCodeInsteadOfIndent())
|
||||
format(cursor);
|
||||
else
|
||||
indent(cursor, QChar::Null);
|
||||
}
|
||||
|
||||
clang::format::FormatStyle ClangFormatBaseIndenter::styleForFile() const
|
||||
{
|
||||
llvm::Expected<clang::format::FormatStyle> style
|
||||
|
||||
Reference in New Issue
Block a user