1
1
mirror of https://github.com/mawww/kakoune.git synced 2024-11-23 15:23:29 +03:00

Go back to previous buffer name completion implementation

This commit is contained in:
Maxime Coste 2015-01-05 19:33:33 +00:00
parent c279da14e3
commit 8e92e0eebc

View File

@ -56,19 +56,25 @@ const PerArgumentCommandCompleter filename_completer({
static CandidateList complete_buffer_name(StringView prefix, ByteCount cursor_pos) static CandidateList complete_buffer_name(StringView prefix, ByteCount cursor_pos)
{ {
const bool include_dirs = contains(prefix.substr(0, cursor_pos), '/'); prefix = prefix.substr(0, cursor_pos);
auto c = transformed(BufferManager::instance(), const bool include_dirs = contains(prefix, '/');
[include_dirs](const safe_ptr<Buffer>& buffer) -> String { CandidateList prefix_result, subsequence_result;
for (auto& buffer : BufferManager::instance())
{
String name = buffer->display_name(); String name = buffer->display_name();
StringView match_name = name;
if (not include_dirs and buffer->flags() & Buffer::Flags::File) if (not include_dirs and buffer->flags() & Buffer::Flags::File)
{ {
ByteCount pos = name.find_last_of('/'); ByteCount pos = name.find_last_of('/');
if (pos != (int)String::npos) if (pos != (int)String::npos)
return name.substr(pos+1); match_name = name.substr(pos+1);
} }
return name; if (prefix_match(match_name, prefix))
}); prefix_result.push_back(name);
return complete(prefix, cursor_pos, c, prefix_match, subsequence_match); if (subsequence_match(name, prefix))
subsequence_result.push_back(name);
}
return prefix_result.empty() ? subsequence_result : prefix_result;
} }
const PerArgumentCommandCompleter buffer_completer({ const PerArgumentCommandCompleter buffer_completer({