diff --git a/src/messages/workspace.cc b/src/messages/workspace.cc index cfa781e2..2e58fe9e 100644 --- a/src/messages/workspace.cc +++ b/src/messages/workspace.cc @@ -27,26 +27,28 @@ REFLECT_STRUCT(SymbolInformation, name, kind, location, containerName); void MessageHandler::workspace_didChangeConfiguration(JsonReader &reader) { auto it = reader.m->FindMember("settings"); - if (it != reader.m->MemberEnd() && it->value.IsObject()) { - rapidjson::StringBuffer output; - rapidjson::Writer writer(output); - JsonReader m1(&it->value); - it->value.Accept(writer); - LOG_S(INFO) << "didChangeConfiguration: " << output.GetString(); - try { - reflect(m1, *g_config); - } catch (std::invalid_argument &) { - reader.path_.push_back("settings"); - reader.path_.insert(reader.path_.end(), m1.path_.begin(), m1.path_.end()); - throw; - } + if (!(it != reader.m->MemberEnd() && it->value.IsObject())) + return; - for (auto &[folder, _] : g_config->workspaceFolders) - project->load(folder); - project->index(wfiles, RequestId()); - - manager->clear(); + // Similar to MessageHandler::initialize. + rapidjson::StringBuffer output; + rapidjson::Writer writer(output); + JsonReader m1(&it->value); + it->value.Accept(writer); + LOG_S(INFO) << "didChangeConfiguration: " << output.GetString(); + try { + reflect(m1, *g_config); + } catch (std::invalid_argument &) { + reader.path_.push_back("settings"); + reader.path_.insert(reader.path_.end(), m1.path_.begin(), m1.path_.end()); + throw; } + + for (auto &[folder, _] : g_config->workspaceFolders) + project->load(folder); + project->index(wfiles, RequestId()); + + manager->clear(); } void MessageHandler::workspace_didChangeWatchedFiles(