Fix use of dead temporary strings in completions
This commit is contained in:
parent
8d37a716fb
commit
8701a53252
|
@ -175,7 +175,10 @@ void ClientManager::redraw_clients() const
|
||||||
CandidateList ClientManager::complete_client_name(StringView prefix,
|
CandidateList ClientManager::complete_client_name(StringView prefix,
|
||||||
ByteCount cursor_pos) const
|
ByteCount cursor_pos) const
|
||||||
{
|
{
|
||||||
auto c = transformed(m_clients, [](const std::unique_ptr<Client>& c){ return c->context().name(); });
|
auto c = transformed(m_clients,
|
||||||
|
[](const std::unique_ptr<Client>& c) -> const String&
|
||||||
|
{ return c->context().name(); });
|
||||||
|
|
||||||
return complete(prefix, cursor_pos, c);
|
return complete(prefix, cursor_pos, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,10 @@ const PerArgumentCommandCompleter filename_completer({
|
||||||
|
|
||||||
static CandidateList complete_buffer_name(StringView prefix, ByteCount cursor_pos)
|
static CandidateList complete_buffer_name(StringView prefix, ByteCount cursor_pos)
|
||||||
{
|
{
|
||||||
auto c = transformed(BufferManager::instance(), [](const SafePtr<Buffer>& b){ return b->display_name(); });
|
auto c = transformed(BufferManager::instance(),
|
||||||
|
[](const SafePtr<Buffer>& b) -> const String&
|
||||||
|
{ return b->display_name(); });
|
||||||
|
|
||||||
return complete(prefix, cursor_pos, c);
|
return complete(prefix, cursor_pos, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -59,6 +59,10 @@ template<typename Container>
|
||||||
CandidateList complete(StringView prefix, ByteCount cursor_pos,
|
CandidateList complete(StringView prefix, ByteCount cursor_pos,
|
||||||
const Container& container)
|
const Container& container)
|
||||||
{
|
{
|
||||||
|
using std::begin;
|
||||||
|
static_assert(not std::is_same<decltype(*begin(container)), String>::value,
|
||||||
|
"complete require long lived strings");
|
||||||
|
|
||||||
prefix = prefix.substr(0, cursor_pos);
|
prefix = prefix.substr(0, cursor_pos);
|
||||||
Vector<RankedMatch> matches;
|
Vector<RankedMatch> matches;
|
||||||
for (const auto& str : container)
|
for (const auto& str : container)
|
||||||
|
|
|
@ -97,7 +97,8 @@ CandidateList FaceRegistry::complete_alias_name(StringView prefix,
|
||||||
using ValueType = std::pair<String, FaceOrAlias>;
|
using ValueType = std::pair<String, FaceOrAlias>;
|
||||||
return complete(prefix, cursor_pos,
|
return complete(prefix, cursor_pos,
|
||||||
transformed(m_aliases,
|
transformed(m_aliases,
|
||||||
[](const ValueType& v){ return v.first; }));
|
[](const ValueType& v) -> const String&
|
||||||
|
{ return v.first; }));
|
||||||
}
|
}
|
||||||
|
|
||||||
FaceRegistry::FaceRegistry()
|
FaceRegistry::FaceRegistry()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user