forked from qt-creator/qt-creator
ClangCodeModel: Do not needlessly update the configuration
... of a document. This fixes the indexing progress bar appearing when opening a source file (unless it has editor defines set). Change-Id: Ia99b226abdb1d5a98a92b23eb4d7311611940b0a Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -736,6 +736,8 @@ void ClangdClient::updateParserConfig(const Utils::FilePath &filePath,
|
|||||||
const CppEditor::BaseEditorDocumentParser::Configuration &config)
|
const CppEditor::BaseEditorDocumentParser::Configuration &config)
|
||||||
{
|
{
|
||||||
// TODO: Also handle usePrecompiledHeaders?
|
// TODO: Also handle usePrecompiledHeaders?
|
||||||
|
// TODO: Should we write the editor defines into the json file? It seems strange
|
||||||
|
// that they should affect the index only while the file is open in the editor.
|
||||||
const auto projectPart = !config.preferredProjectPartId.isEmpty()
|
const auto projectPart = !config.preferredProjectPartId.isEmpty()
|
||||||
? CppEditor::CppModelManager::instance()->projectPartForId(
|
? CppEditor::CppModelManager::instance()->projectPartForId(
|
||||||
config.preferredProjectPartId)
|
config.preferredProjectPartId)
|
||||||
@@ -745,10 +747,15 @@ void ClangdClient::updateParserConfig(const Utils::FilePath &filePath,
|
|||||||
|
|
||||||
CppEditor::BaseEditorDocumentParser::Configuration fullConfig = config;
|
CppEditor::BaseEditorDocumentParser::Configuration fullConfig = config;
|
||||||
fullConfig.preferredProjectPartId = projectPart->id();
|
fullConfig.preferredProjectPartId = projectPart->id();
|
||||||
CppEditor::BaseEditorDocumentParser::Configuration &cachedConfig = d->parserConfigs[filePath];
|
auto cachedConfig = d->parserConfigs.find(filePath);
|
||||||
if (cachedConfig == fullConfig)
|
if (cachedConfig == d->parserConfigs.end()) {
|
||||||
|
cachedConfig = d->parserConfigs.insert(filePath, fullConfig);
|
||||||
|
if (config.preferredProjectPartId.isEmpty() && config.editorDefines.isEmpty())
|
||||||
|
return;
|
||||||
|
} else if (cachedConfig.value() == fullConfig) {
|
||||||
return;
|
return;
|
||||||
cachedConfig = fullConfig;
|
}
|
||||||
|
cachedConfig.value() = fullConfig;
|
||||||
|
|
||||||
QJsonObject cdbChanges;
|
QJsonObject cdbChanges;
|
||||||
const Utils::FilePath includeDir = CppEditor::ClangdSettings(d->settings).clangdIncludePath();
|
const Utils::FilePath includeDir = CppEditor::ClangdSettings(d->settings).clangdIncludePath();
|
||||||
|
Reference in New Issue
Block a user