Rename prefix to query in complete helper function and tweak static_assert
This commit is contained in:
parent
761d316af6
commit
1fd7e80f04
|
@ -56,18 +56,18 @@ inline Completions offset_pos(Completions completion, ByteCount offset)
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Container>
|
template<typename Container>
|
||||||
CandidateList complete(StringView prefix, ByteCount cursor_pos,
|
CandidateList complete(StringView query, ByteCount cursor_pos,
|
||||||
const Container& container)
|
const Container& container)
|
||||||
{
|
{
|
||||||
using std::begin;
|
using std::begin;
|
||||||
static_assert(not std::is_same<decltype(*begin(container)), String>::value,
|
static_assert(not std::is_same<decltype(*begin(container)), String>::value,
|
||||||
"complete require long lived strings");
|
"complete require long lived strings, not temporaries");
|
||||||
|
|
||||||
prefix = prefix.substr(0, cursor_pos);
|
query = query.substr(0, cursor_pos);
|
||||||
Vector<RankedMatch> matches;
|
Vector<RankedMatch> matches;
|
||||||
for (const auto& str : container)
|
for (const auto& str : container)
|
||||||
{
|
{
|
||||||
if (RankedMatch match{str, prefix})
|
if (RankedMatch match{str, query})
|
||||||
matches.push_back(match);
|
matches.push_back(match);
|
||||||
}
|
}
|
||||||
std::sort(matches.begin(), matches.end());
|
std::sort(matches.begin(), matches.end());
|
||||||
|
|
Loading…
Reference in New Issue
Block a user