diff options
author | Christian Kandeler <christian.kandeler@qt.io> | 2023-06-30 15:16:28 +0200 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@qt.io> | 2023-07-03 08:47:42 +0000 |
commit | a39119669c3c040c612416fb88a0366e0852f2f3 (patch) | |
tree | 94c31c09f3296f846c48c86da6474c9ac6e21499 /src/plugins/texteditor/refactoringchanges.cpp | |
parent | 64c8c37bd479a4d1d284e552e5c02e47a288ff0a (diff) |
CppEditor: Format quickfix code only if formatting is enabled
... in the ClangFormat settings (rather than the default of just
indenting).
As opposed to files generated by the wizard, quickfixes are often touching
existing code, and since ClangFormat works on line granularity, users
will experience unexpected re-formattings when ClangFormat is in indent-
only mode.
Therefore, do the formatting only if the user has enabled it in the
ClangFormat settings.
Change-Id: Icb30f166f2b6fb94113a8f25c4a5f92ff8bca9b0
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'src/plugins/texteditor/refactoringchanges.cpp')
-rw-r--r-- | src/plugins/texteditor/refactoringchanges.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/plugins/texteditor/refactoringchanges.cpp b/src/plugins/texteditor/refactoringchanges.cpp index 1b03a07e01..c432e22430 100644 --- a/src/plugins/texteditor/refactoringchanges.cpp +++ b/src/plugins/texteditor/refactoringchanges.cpp @@ -473,7 +473,13 @@ void RefactoringFile::doFormatting() b = b.next(); } } - m_editor->textDocument()->indenter()->format(formattingRanges); + + // TODO: The proper solution seems to be to call formatOrIndent() here (and not + // use hardcoded indent regions anymore), but that would require intrusive changes + // to the C++ quickfixes and tests, where we rely on the built-in indenter behavior. + m_editor->textDocument()->indenter()->format(formattingRanges, + Indenter::FormattingMode::Settings); + for (QTextBlock b = m_editor->document()->findBlockByNumber( formattingRanges.front().startLine - 1); b.isValid(); b = b.next()) { QString blockText = b.text(); |