forked from qt-creator/qt-creator
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>
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user