diff --git a/src/source_language_protocol.cpp b/src/source_language_protocol.cpp index 269abaa..0254999 100644 --- a/src/source_language_protocol.cpp +++ b/src/source_language_protocol.cpp @@ -996,20 +996,23 @@ void Source::LanguageProtocolView::update_diagnostics_async(std::vectorbegin(); - auto end = get_buffer()->end(); - auto range = "{\"start\":{\"line\": " + std::to_string(start.get_line()) + ",\"character\":" + std::to_string(start.get_line_offset()) + R"(},"end":{"line":)" + std::to_string(end.get_line()) + ",\"character\":" + std::to_string(end.get_line_offset()) + "}}"; + if(diagnostics.size() != 1) { // Use diagnostic range if only one diagnostic, otherwise use whole buffer + auto start = get_buffer()->begin(); + auto end = get_buffer()->end(); + range = "{\"start\":{\"line\": " + std::to_string(start.get_line()) + ",\"character\":" + std::to_string(start.get_line_offset()) + R"(},"end":{"line":)" + std::to_string(end.get_line()) + ",\"character\":" + std::to_string(end.get_line_offset()) + "}}"; + } auto request = (R"("textDocument":{"uri":")" + uri + "\"},\"range\":" + range + ",\"context\":{\"diagnostics\":[" + diagnostics_string + "],\"only\":[\"quickfix\"]}"); thread_pool.push([this, diagnostics = std::move(diagnostics), request = std::move(request), last_count]() mutable {