forked from qt-creator/qt-creator
ClangFormat: Fix crashes when new project is created
Indenter is used by wizards so make sure it works. Change-Id: If26eae322e26bf2e32cb86acf45e7b3d33b67e98 Reviewed-by: Marco Bubke <marco.bubke@qt.io>
This commit is contained in:
@@ -357,8 +357,10 @@ TextEditor::Replacements ClangFormatBaseIndenter::replacements(QByteArray buffer
|
||||
adjustFormatStyleForLineBreak(style, replacementsToKeep);
|
||||
if (typedChar == QChar::Null) {
|
||||
if (replacementsToKeep == ReplacementsToKeep::IndentAndBefore) {
|
||||
if (utf8Offset > 0) {
|
||||
buffer.insert(utf8Offset - 1, " //");
|
||||
utf8Offset += 3;
|
||||
}
|
||||
utf8Length += forceIndentWithExtraText(buffer,
|
||||
cursorPositionInEditor < 0
|
||||
? endBlock
|
||||
|
@@ -84,7 +84,10 @@ Utils::optional<TabSettings> ClangFormatIndenter::tabSettings() const
|
||||
|
||||
int ClangFormatIndenter::lastSaveRevision() const
|
||||
{
|
||||
return qobject_cast<TextEditor::TextDocumentLayout *>(m_doc->documentLayout())->lastSaveRevision;
|
||||
auto *layout = qobject_cast<TextEditor::TextDocumentLayout *>(m_doc->documentLayout());
|
||||
if (!layout)
|
||||
return 0;
|
||||
return layout->lastSaveRevision;
|
||||
}
|
||||
|
||||
bool ClangFormatIndenter::formatOnSave() const
|
||||
|
Reference in New Issue
Block a user