mirror of
https://github.com/mawww/kakoune.git
synced 2024-12-01 08:23:05 +03:00
Add ClientManager::complete_client_name
This commit is contained in:
parent
a9b3a8b0d6
commit
ca54909246
@ -166,4 +166,22 @@ void ClientManager::redraw_clients() const
|
||||
client->redraw_ifn();
|
||||
}
|
||||
|
||||
CandidateList ClientManager::complete_client_name(const String& prefix,
|
||||
ByteCount cursor_pos) const
|
||||
{
|
||||
String real_prefix = prefix.substr(0, cursor_pos);
|
||||
CandidateList result;
|
||||
CandidateList subsequence_result;
|
||||
for (auto& client : m_clients)
|
||||
{
|
||||
const String& name = client->context().name();
|
||||
|
||||
if (prefix_match(name, real_prefix))
|
||||
result.push_back(escape(name));
|
||||
if (subsequence_match(name, real_prefix))
|
||||
subsequence_result.push_back(escape(name));
|
||||
}
|
||||
return result.empty() ? subsequence_result : result;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
#define client_manager_hh_INCLUDED
|
||||
|
||||
#include "client.hh"
|
||||
#include "completion.hh"
|
||||
|
||||
namespace Kakoune
|
||||
{
|
||||
@ -38,6 +39,9 @@ public:
|
||||
bool validate_client_name(const String& name) const;
|
||||
void remove_client(Client& client);
|
||||
|
||||
CandidateList complete_client_name(const String& name,
|
||||
ByteCount cursor_pos = -1) const;
|
||||
|
||||
private:
|
||||
String generate_name() const;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user