ClangFormat: Fix preview update

Fixes: QTCREATORBUG-30089
Change-Id: Id89e8b2ee0439c5235755256e8410f42ad94b432
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Artem Sokolovskii
2023-12-18 17:20:30 +01:00
parent bbf02473e0
commit a0cc2e3c3e
4 changed files with 24 additions and 3 deletions

View File

@@ -782,7 +782,8 @@ void ClangFormatBaseIndenter::autoIndent(const QTextCursor &cursor,
}
}
clang::format::FormatStyle overrideStyle(const Utils::FilePath &fileName)
clang::format::FormatStyle ClangFormatBaseIndenter::overrideStyle(
const Utils::FilePath &fileName) const
{
const ProjectExplorer::Project *projectForFile
= ProjectExplorer::ProjectManager::projectForFile(fileName);
@@ -792,6 +793,9 @@ clang::format::FormatStyle overrideStyle(const Utils::FilePath &fileName)
? projectForFile->editorConfiguration()->codeStyle("Cpp")->currentPreferences()
: TextEditor::TextEditorSettings::codeStyle("Cpp")->currentPreferences();
if (m_overriddenPreferences)
preferences = m_overriddenPreferences->currentPreferences();
Utils::FilePath filePath = filePathToCurrentSettings(preferences);
if (!filePath.exists())
@@ -854,4 +858,9 @@ const clang::format::FormatStyle &ClangFormatBaseIndenter::styleForFile() const
return m_cachedStyle.style;
}
void ClangFormatBaseIndenter::setOverriddenPreferences(TextEditor::ICodeStylePreferences *preferences)
{
m_overriddenPreferences = preferences;
}
} // namespace ClangFormat