diff --git a/src/source.h b/src/source.h index 05f9a66..87876d2 100644 --- a/src/source.h +++ b/src/source.h @@ -27,12 +27,15 @@ namespace Source { class Offset { public: Offset() = default; - Offset(unsigned line, unsigned index, boost::filesystem::path file_path_ = "") : line(line), index(index), file_path(std::move(file_path_)) {} - operator bool() { return !file_path.empty(); } - bool operator==(const Offset &o) { return (line == o.line && index == o.index); } - - unsigned line; - unsigned index; + 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))); + } + bool operator==(const Offset &rhs) const { return (file_path == rhs.file_path && line == rhs.line && index == rhs.index); } + + unsigned line = 0; + unsigned index = 0; boost::filesystem::path file_path; }; diff --git a/src/source_language_protocol.cc b/src/source_language_protocol.cc index b1c5949..f84ccdb 100644 --- a/src/source_language_protocol.cc +++ b/src/source_language_protocol.cc @@ -881,6 +881,9 @@ void Source::LanguageProtocolView::setup_navigation_and_refactoring() { }); result_processed.get_future().get(); + std::sort(methods.begin(), methods.end(), [](const std::pair &a, const std::pair &b) { + return a.first < b.first; + }); return methods; }; }