From 8cd69256cc7582a1ff8594101869188c3d1528a0 Mon Sep 17 00:00:00 2001 From: eidheim Date: Sun, 28 Jan 2018 19:17:47 +0100 Subject: [PATCH] Language protocol: fixed delay on language protocol errors, and added terminal warning on such errors. --- src/source_language_protocol.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/source_language_protocol.cc b/src/source_language_protocol.cc index 3f651b1..644cfed 100644 --- a/src/source_language_protocol.cc +++ b/src/source_language_protocol.cc @@ -219,9 +219,9 @@ void LanguageProtocol::Client::parse_server_message() { void LanguageProtocol::Client::write_request(const std::string &method, const std::string ¶ms, std::function &&function) { std::unique_lock lock(read_write_mutex); - if(function) + if(function) { handlers.emplace(message_id, std::move(function)); - { + auto message_id=this->message_id; std::unique_lock lock(timeout_threads_mutex); timeout_threads.emplace_back([this, message_id] { @@ -248,7 +248,8 @@ void LanguageProtocol::Client::write_request(const std::string &method, const st if(output_messages_and_errors) std::cout << "Language client: " << content << std::endl; if(!process->write(message)) { - auto id_it=handlers.find(message_id); + Terminal::get().async_print("Error writing to language protocol server. Please close and reopen all project source files.\n", true); + auto id_it=handlers.find(message_id-1); if(id_it!=handlers.end()) { auto function=std::move(id_it->second); handlers.erase(id_it->first);