Fix removal of duplicated words in insert completion

This commit is contained in:
Maxime Coste 2015-10-19 19:39:05 +01:00
parent 73e438be07
commit 9449f763e0

View File

@ -127,8 +127,12 @@ InsertCompletion complete_word(const Buffer& buffer, ByteCoord cursor_pos)
} }
} }
unordered_erase(matches, StringView{prefix}); unordered_erase(matches, StringView{prefix});
std::sort(matches.begin(), matches.end()); std::sort(matches.begin(), matches.end(),
[](const RankedWordAndBuffer& lhs, const RankedWordAndBuffer& rhs) {
return lhs.word < rhs.word;
});
matches.erase(std::unique(matches.begin(), matches.end()), matches.end()); matches.erase(std::unique(matches.begin(), matches.end()), matches.end());
std::sort(matches.begin(), matches.end());
const auto longest = std::accumulate(matches.begin(), matches.end(), 0_char, const auto longest = std::accumulate(matches.begin(), matches.end(), 0_char,
[](const CharCount& lhs, const RankedWordAndBuffer& rhs) [](const CharCount& lhs, const RankedWordAndBuffer& rhs)