diff --git a/src/command_line.cc b/src/command_line.cc index bd913242..5936f7f7 100644 --- a/src/command_line.cc +++ b/src/command_line.cc @@ -990,14 +990,6 @@ void ParseFile(IndexerConfig* config, for (std::unique_ptr& new_index : indexes) { std::cerr << "Got index for " << new_index->path << std::endl; - // Publish diagnostics. - if (!new_index->diagnostics.empty()) { - Out_TextDocumentPublishDiagnostics diag; - diag.params.uri = lsDocumentUri::FromPath(new_index->path); - diag.params.diagnostics = new_index->diagnostics; - IpcManager::instance()->SendOutMessageToClient(IpcId::TextDocumentPublishDiagnostics, diag); - } - // Load the cached index. std::unique_ptr cached_index; if (cache_for_args && new_index->path == cache_for_args->path) @@ -1009,6 +1001,15 @@ void ParseFile(IndexerConfig* config, time.ResetAndPrint("Loading cached index"); + // Publish diagnostics. + if (!new_index->diagnostics.empty() || (cached_index && !cached_index->diagnostics.empty())) { + Out_TextDocumentPublishDiagnostics diag; + diag.params.uri = lsDocumentUri::FromPath(new_index->path); + diag.params.diagnostics = new_index->diagnostics; + IpcManager::instance()->SendOutMessageToClient(IpcId::TextDocumentPublishDiagnostics, diag); + } + + // Any any existing dependencies to |new_index| that were there before, // because we will not reparse them if they haven't changed. // TODO: indexer should always include dependencies. This doesn't let us remove old dependencies. @@ -1542,7 +1543,7 @@ bool QueryDbMainLoop( working_file->pending_new_index_content = working_file->buffer_content; queue_do_index->Enqueue(Index_DoIndex(Index_DoIndex::Type::Parse, project->FindCompilationEntryForFile(path))); } - completion_manager->DropAllSessionsExcept(path); + completion_manager->DropAllSessionsExcept(""); break; } diff --git a/src/serializer.cc b/src/serializer.cc index afcfa9e6..e3f8c303 100644 --- a/src/serializer.cc +++ b/src/serializer.cc @@ -232,6 +232,7 @@ void Reflect(TVisitor& visitor, IndexedFile& value) { REFLECT_MEMBER(import_file); REFLECT_MEMBER(args); } + REFLECT_MEMBER(diagnostics); REFLECT_MEMBER(dependencies); REFLECT_MEMBER(types); REFLECT_MEMBER(funcs); @@ -288,4 +289,4 @@ optional Deserialize(std::string path, std::string serialized) { void SetTestOutputMode() { gTestOutputMode = true; -} \ No newline at end of file +}