Skip to content

Commit e55cc68

Browse files
committed
workspace: Make didChangeConfiguration use its parameter
to update the configuration settings.
1 parent 3640f89 commit e55cc68

File tree

2 files changed

+26
-7
lines changed

2 files changed

+26
-7
lines changed

src/message_handler.hh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ private:
313313
void textDocument_signatureHelp(TextDocumentPositionParam &, ReplyOnce &);
314314
void textDocument_switchSourceHeader(TextDocumentIdentifier &, ReplyOnce &);
315315
void textDocument_typeDefinition(TextDocumentPositionParam &, ReplyOnce &);
316-
void workspace_didChangeConfiguration(EmptyParam &);
316+
void workspace_didChangeConfiguration(JsonReader &);
317317
void workspace_didChangeWatchedFiles(DidChangeWatchedFilesParam &);
318318
void workspace_didChangeWorkspaceFolders(DidChangeWorkspaceFoldersParam &);
319319
void workspace_executeCommand(JsonReader &, ReplyOnce &);

src/messages/workspace.cc

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
#include <llvm/ADT/StringRef.h>
1414
#include <llvm/Support/Path.h>
1515

16+
#include <rapidjson/document.h>
17+
#include <rapidjson/writer.h>
18+
1619
#include <algorithm>
1720
#include <ctype.h>
1821
#include <functional>
@@ -22,13 +25,29 @@ using namespace llvm;
2225
namespace ccls {
2326
REFLECT_STRUCT(SymbolInformation, name, kind, location, containerName);
2427

25-
void MessageHandler::workspace_didChangeConfiguration(EmptyParam &) {
26-
for (auto &[folder, _] : g_config->workspaceFolders)
27-
project->load(folder);
28-
project->index(wfiles, RequestId());
28+
void MessageHandler::workspace_didChangeConfiguration(JsonReader &reader) {
29+
auto it = reader.m->FindMember("settings");
30+
if (it != reader.m->MemberEnd() && it->value.IsObject()) {
31+
rapidjson::StringBuffer output;
32+
rapidjson::Writer<rapidjson::StringBuffer> writer(output);
33+
JsonReader m1(&it->value);
34+
it->value.Accept(writer);
35+
LOG_S(INFO) << "didChangeConfiguration: " << output.GetString();
36+
try {
37+
reflect(m1, *g_config);
38+
} catch (std::invalid_argument &) {
39+
reader.path_.push_back("settings");
40+
reader.path_.insert(reader.path_.end(), m1.path_.begin(), m1.path_.end());
41+
throw;
42+
}
2943

30-
manager->clear();
31-
};
44+
for (auto &[folder, _] : g_config->workspaceFolders)
45+
project->load(folder);
46+
project->index(wfiles, RequestId());
47+
48+
manager->clear();
49+
}
50+
}
3251

3352
void MessageHandler::workspace_didChangeWatchedFiles(
3453
DidChangeWatchedFilesParam &param) {

0 commit comments

Comments
 (0)