diff --git a/src/source.hpp b/src/source.hpp index a6229e7..d7e0b86 100644 --- a/src/source.hpp +++ b/src/source.hpp @@ -30,7 +30,9 @@ namespace Source { Offset(unsigned line, unsigned index, boost::filesystem::path file_path_ = {}) : line(line), index(index), file_path(std::move(file_path_)) {} operator bool() const { return !file_path.empty(); } bool operator<(const Offset &rhs) const { - return file_path < rhs.file_path || (file_path == rhs.file_path && (line < rhs.line || (line == rhs.line && index < rhs.index))); + return file_path < rhs.file_path || + (file_path == rhs.file_path && (line < rhs.line || + (line == rhs.line && index < rhs.index))); } bool operator==(const Offset &rhs) const { return (file_path == rhs.file_path && line == rhs.line && index == rhs.index); } @@ -55,6 +57,17 @@ namespace Source { std::string source; std::string path; std::pair offsets; + + bool operator<(const FixIt &rhs) const { + + return type < rhs.type || + (type == rhs.type && (source < rhs.source || + (source == rhs.source && (path < rhs.path || + (path == rhs.path && offsets < rhs.offsets))))); + } + bool operator==(const FixIt &rhs) const { + return type == rhs.type && source == rhs.source && path == rhs.path && offsets == rhs.offsets; + } }; class View : public SpellCheckView, public DiffView { diff --git a/src/source_language_protocol.cpp b/src/source_language_protocol.cpp index 0254999..a88fc13 100644 --- a/src/source_language_protocol.cpp +++ b/src/source_language_protocol.cpp @@ -1038,8 +1038,8 @@ void Source::LanguageProtocolView::update_diagnostics_async(std::vector{}); - pair.first->second.emplace_back( + auto pair = diagnostic.quickfixes.emplace(title, std::set{}); + pair.first->second.emplace( edit.new_text, filesystem::get_path_from_uri(file_it->first).string(), std::make_pair(Offset(edit.range.start.line, edit.range.start.character), @@ -1052,8 +1052,8 @@ void Source::LanguageProtocolView::update_diagnostics_async(std::vector{}); - pair.first->second.emplace_back( + auto pair = diagnostic.quickfixes.emplace(title, std::set{}); + pair.first->second.emplace( edit.new_text, filesystem::get_path_from_uri(file_it->first).string(), std::make_pair(Offset(edit.range.start.line, edit.range.start.character), diff --git a/src/source_language_protocol.hpp b/src/source_language_protocol.hpp index 4fa77e1..ba26ca9 100644 --- a/src/source_language_protocol.hpp +++ b/src/source_language_protocol.hpp @@ -71,7 +71,7 @@ namespace LanguageProtocol { Range range; int severity; std::vector related_informations; - std::map> quickfixes; + std::map> quickfixes; }; class TextEdit {