diff options
author | Ivan Donchevskii <ivan.donchevskii@qt.io> | 2019-01-28 08:13:33 +0100 |
---|---|---|
committer | Ivan Donchevskii <ivan.donchevskii@qt.io> | 2019-02-05 08:36:06 +0000 |
commit | 536b733f2978cf81d72cc01572bf6338248aac2d (patch) | |
tree | 9ab17ae2b617c54d2e7c44461e87546f2c2d2bd5 /src/plugins/clangformat/clangformatsettings.cpp | |
parent | 68bce815ac4c53251df4c1038596ea87469562da (diff) |
ClangFormat: Format more code while typing
With the extra option "Format while typing" checked try to format
text before the current position without breaking the current input.
To accomplish that we make proper choices which replacements to apply.
The advantage of this change is to decrease the need to manually
format code which is just written.
Some minor bugs are fixed during the testing of this change.
Change-Id: Ibed569042e6c46a881e7a83b1882cf2bb23b3626
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
Diffstat (limited to 'src/plugins/clangformat/clangformatsettings.cpp')
-rw-r--r-- | src/plugins/clangformat/clangformatsettings.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/plugins/clangformat/clangformatsettings.cpp b/src/plugins/clangformat/clangformatsettings.cpp index 0547bde960..d8369bf5ef 100644 --- a/src/plugins/clangformat/clangformatsettings.cpp +++ b/src/plugins/clangformat/clangformatsettings.cpp @@ -42,6 +42,8 @@ ClangFormatSettings::ClangFormatSettings() settings->beginGroup(QLatin1String(Constants::SETTINGS_ID)); m_formatCodeInsteadOfIndent = settings->value(QLatin1String(Constants::FORMAT_CODE_INSTEAD_OF_INDENT_ID), false).toBool(); + m_formatWhileTyping = settings->value(QLatin1String(Constants::FORMAT_WHILE_TYPING_ID), false) + .toBool(); settings->endGroup(); } @@ -51,6 +53,7 @@ void ClangFormatSettings::write() const settings->beginGroup(QLatin1String(Constants::SETTINGS_ID)); settings->setValue(QLatin1String(Constants::FORMAT_CODE_INSTEAD_OF_INDENT_ID), m_formatCodeInsteadOfIndent); + settings->setValue(QLatin1String(Constants::FORMAT_WHILE_TYPING_ID), m_formatWhileTyping); settings->endGroup(); } @@ -64,4 +67,14 @@ bool ClangFormatSettings::formatCodeInsteadOfIndent() const return m_formatCodeInsteadOfIndent; } +void ClangFormatSettings::setFormatWhileTyping(bool enable) +{ + m_formatWhileTyping = enable; +} + +bool ClangFormatSettings::formatWhileTyping() const +{ + return m_formatWhileTyping; +} + } // namespace ClangFormat |