From 9018bc47dfe14ef45e7dced7a0bfec84b1be1a0f Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Tue, 24 Sep 2013 01:54:55 +0200 Subject: [PATCH] use subsequence instead of regex matching for buffer completion --- src/buffer_manager.cc | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/src/buffer_manager.cc b/src/buffer_manager.cc index c830d011..5f3fe1ec 100644 --- a/src/buffer_manager.cc +++ b/src/buffer_manager.cc @@ -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; } }