Code cleanups

This commit is contained in:
Maxime Coste 2016-03-14 13:38:46 +00:00
parent 3a699c8ac3
commit 7ecd65e1af
3 changed files with 7 additions and 15 deletions

View File

@ -61,7 +61,7 @@ static CandidateList complete_buffer_name(StringView query, ByteCount cursor_pos
{ {
struct RankedMatchAndBuffer : RankedMatch struct RankedMatchAndBuffer : RankedMatch
{ {
RankedMatchAndBuffer(const RankedMatch& m, const Buffer* b = nullptr) RankedMatchAndBuffer(const RankedMatch& m, const Buffer* b)
: RankedMatch{m}, buffer{b} {} : RankedMatch{m}, buffer{b} {}
using RankedMatch::operator==; using RankedMatch::operator==;

View File

@ -97,7 +97,7 @@ InsertCompletion complete_word(const Buffer& buffer, ByteCoord cursor_pos, const
struct RankedMatchAndBuffer : RankedMatch struct RankedMatchAndBuffer : RankedMatch
{ {
RankedMatchAndBuffer(const RankedMatch& m, const Buffer* b = nullptr) RankedMatchAndBuffer(const RankedMatch& m, const Buffer* b)
: RankedMatch{m}, buffer{b} {} : RankedMatch{m}, buffer{b} {}
using RankedMatch::operator==; using RankedMatch::operator==;
@ -130,18 +130,10 @@ InsertCompletion complete_word(const Buffer& buffer, ByteCoord cursor_pos, const
} }
} }
{ using StaticWords = Vector<String, MemoryDomain::Options>;
using StaticWords = Vector<String, MemoryDomain::Options>; for (auto& word : options["static_words"].get<StaticWords>())
const StaticWords& static_words = options["static_words"].get<StaticWords>(); if (RankedMatch match{word, prefix})
matches.emplace_back(match, nullptr);
for (auto& word : static_words)
{
if (prefix.empty())
matches.push_back(RankedMatch{word, prefix});
else if (RankedMatch match{word, prefix})
matches.push_back(match);
}
}
unordered_erase(matches, StringView{prefix}); unordered_erase(matches, StringView{prefix});
std::sort(matches.begin(), matches.end()); std::sort(matches.begin(), matches.end());

View File

@ -8,7 +8,7 @@
namespace Kakoune namespace Kakoune
{ {
class Value; struct Value;
class JsonUI : public UserInterface class JsonUI : public UserInterface
{ {