diff options
author | Ivan Donchevskii <ivan.donchevskii@qt.io> | 2019-01-28 12:25:36 +0100 |
---|---|---|
committer | Ivan Donchevskii <ivan.donchevskii@qt.io> | 2019-02-05 08:36:16 +0000 |
commit | 5792291520fb128764264140497233b5545c375d (patch) | |
tree | ad34556b02db441e0ae692f0e33d6bfb9a5cd14f /src/plugins/clangformat/clangformatsettings.cpp | |
parent | 536b733f2978cf81d72cc01572bf6338248aac2d (diff) |
ClangFormat: Format edited chunks of file on save
The similar implementation to the one in Beautifier plugin
with the difference that the clangformat indenter logic is used
and only modified chunks are formatted.
That means that all code which was not touched will stay in the
initial condition.
Change-Id: I47b11eb99852454ed0031ef6cfc6dbed1ecd390d
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 d8369bf5ef..8be2b3cefe 100644 --- a/src/plugins/clangformat/clangformatsettings.cpp +++ b/src/plugins/clangformat/clangformatsettings.cpp @@ -44,6 +44,8 @@ ClangFormatSettings::ClangFormatSettings() = settings->value(QLatin1String(Constants::FORMAT_CODE_INSTEAD_OF_INDENT_ID), false).toBool(); m_formatWhileTyping = settings->value(QLatin1String(Constants::FORMAT_WHILE_TYPING_ID), false) .toBool(); + m_formatOnSave = settings->value(QLatin1String(Constants::FORMAT_CODE_ON_SAVE_ID), false) + .toBool(); settings->endGroup(); } @@ -54,6 +56,7 @@ void ClangFormatSettings::write() const settings->setValue(QLatin1String(Constants::FORMAT_CODE_INSTEAD_OF_INDENT_ID), m_formatCodeInsteadOfIndent); settings->setValue(QLatin1String(Constants::FORMAT_WHILE_TYPING_ID), m_formatWhileTyping); + settings->setValue(QLatin1String(Constants::FORMAT_CODE_ON_SAVE_ID), m_formatOnSave); settings->endGroup(); } @@ -77,4 +80,14 @@ bool ClangFormatSettings::formatWhileTyping() const return m_formatWhileTyping; } +void ClangFormatSettings::setFormatOnSave(bool enable) +{ + m_formatOnSave = enable; +} + +bool ClangFormatSettings::formatOnSave() const +{ + return m_formatOnSave; +} + } // namespace ClangFormat |