use subsequence instead of regex matching for buffer completion

This commit is contained in:
Maxime Coste 2013-09-24 01:54:55 +02:00
parent bab10f5b93
commit 9018bc47df

View File

@ -100,28 +100,16 @@ CandidateList BufferManager::complete_buffername(const String& prefix,
{
String real_prefix = prefix.substr(0, cursor_pos);
CandidateList result;
CandidateList subsequence_result;
for (auto& buffer : m_buffers)
{
String name = buffer->display_name();
if (prefix_match(name, real_prefix))
result.push_back(escape(name));
if (subsequence_match(name, real_prefix))
subsequence_result.push_back(escape(name));
}
// no prefix completion found, check regex matching
if (result.empty())
{
try
{
Regex ex(real_prefix.begin(), real_prefix.end());
for (auto& buffer : m_buffers)
{
String name = buffer->display_name();
if (boost::regex_search(name.begin(), name.end(), ex))
result.push_back(escape(name));
}
}
catch (boost::regex_error& err) {}
}
return result;
return result.empty() ? subsequence_result : result;
}
}