forked from qt-creator/qt-creator
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>
This commit is contained in:
@@ -28,6 +28,7 @@
|
||||
#include "clangformatutils.h"
|
||||
|
||||
#include <texteditor/tabsettings.h>
|
||||
#include <texteditor/textdocumentlayout.h>
|
||||
|
||||
using namespace clang;
|
||||
using namespace format;
|
||||
@@ -49,6 +50,11 @@ bool ClangFormatIndenter::formatCodeInsteadOfIndent() const
|
||||
return ClangFormatSettings::instance().formatCodeInsteadOfIndent();
|
||||
}
|
||||
|
||||
bool ClangFormatIndenter::formatWhileTyping() const
|
||||
{
|
||||
return ClangFormatSettings::instance().formatWhileTyping();
|
||||
}
|
||||
|
||||
Utils::optional<TabSettings> ClangFormatIndenter::tabSettings() const
|
||||
{
|
||||
FormatStyle style = currentProjectStyle();
|
||||
@@ -76,4 +82,9 @@ Utils::optional<TabSettings> ClangFormatIndenter::tabSettings() const
|
||||
return tabSettings;
|
||||
}
|
||||
|
||||
int ClangFormatIndenter::lastSaveRevision() const
|
||||
{
|
||||
return qobject_cast<TextEditor::TextDocumentLayout *>(m_doc->documentLayout())->lastSaveRevision;
|
||||
}
|
||||
|
||||
} // namespace ClangFormat
|
||||
|
||||
Reference in New Issue
Block a user