From 44a99fdbc45cad98f59ec1a77ae2bd4a81a91696 Mon Sep 17 00:00:00 2001 From: eidheim Date: Tue, 18 Jun 2019 12:06:51 +0200 Subject: [PATCH] Language protocol: can no longer edit text while waiting for capabilities during initialization, and some cleanups --- src/source_language_protocol.cc | 8 +++++--- src/source_language_protocol.h | 26 +++++++++++++------------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/src/source_language_protocol.cc b/src/source_language_protocol.cc index 2740fd2..38fdf0a 100644 --- a/src/source_language_protocol.cc +++ b/src/source_language_protocol.cc @@ -15,7 +15,7 @@ #include #include -const std::string flow_coverage_message = "Not covered by Flow"; +const std::string type_coverage_message = "Un-type checked code. Consider adding type annotations."; LanguageProtocol::Offset::Offset(const boost::property_tree::ptree &pt) : line(pt.get("line")), character(pt.get("character")) {} @@ -397,11 +397,13 @@ void Source::LanguageProtocolView::initialize(bool setup) { if(update_status_state) update_status_state(this); + set_sensitive(false); initialize_thread = std::thread([this, setup] { auto capabilities = client->initialize(this); dispatcher.post([this, capabilities, setup] { this->capabilities = capabilities; + set_sensitive(true); std::string text = get_buffer()->get_text(); escape_text(text); @@ -965,7 +967,7 @@ void Source::LanguageProtocolView::update_diagnostics(std::vectorget_iter(), mark.second->get_iter(), false, [](const Glib::RefPtr &buffer) { - buffer->insert_at_cursor(flow_coverage_message); + buffer->insert_at_cursor(type_coverage_message); }); status_diagnostics = std::make_tuple(num_warnings, num_errors, num_fix_its); @@ -1506,7 +1508,7 @@ void Source::LanguageProtocolView::update_type_coverage() { auto start = get_iter_at_line_offset(range.start.line, range.start.character); auto end = get_iter_at_line_offset(range.end.line, range.end.character); add_diagnostic_tooltip(start, end, false, [](const Glib::RefPtr &buffer) { - buffer->insert_at_cursor(flow_coverage_message); + buffer->insert_at_cursor(type_coverage_message); }); type_coverage_marks.emplace_back(get_buffer()->create_mark(start), get_buffer()->create_mark(end)); diff --git a/src/source_language_protocol.h b/src/source_language_protocol.h index 80a7357..6f5a16a 100644 --- a/src/source_language_protocol.h +++ b/src/source_language_protocol.h @@ -83,19 +83,19 @@ namespace LanguageProtocol { enum class TextDocumentSync { NONE = 0, FULL, INCREMENTAL }; - TextDocumentSync text_document_sync; - bool hover; - bool completion; - bool signature_help; - bool definition; - bool references; - bool document_highlight; - bool workspace_symbol; - bool document_symbol; - bool document_formatting; - bool document_range_formatting; - bool rename; - bool type_coverage; + TextDocumentSync text_document_sync = TextDocumentSync::NONE; + bool hover = false; + bool completion = false; + bool signature_help = false; + bool definition = false; + bool references = false; + bool document_highlight = false; + bool workspace_symbol = false; + bool document_symbol = false; + bool document_formatting = false; + bool document_range_formatting = false; + bool rename = false; + bool type_coverage = false; }; class Client {