From e00c81171248268cd7f61c0a9e139a8065b48eed Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Tue, 14 Aug 2012 14:26:36 +0200 Subject: [PATCH] complete_buffername try regex matching when prefix matching does not work --- src/buffer_manager.cc | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/buffer_manager.cc b/src/buffer_manager.cc index 9aba924d..c5235cb1 100644 --- a/src/buffer_manager.cc +++ b/src/buffer_manager.cc @@ -3,6 +3,7 @@ #include "assert.hh" #include "buffer.hh" #include "exception.hh" +#include "regex.hh" namespace Kakoune { @@ -62,6 +63,17 @@ CandidateList BufferManager::complete_buffername(const String& prefix, if (name.substr(0, real_prefix.length()) == real_prefix) result.push_back(name); } + // no prefix completion found, check regex matching + if (result.empty()) + { + Regex ex(real_prefix.begin(), real_prefix.end()); + for (auto& buffer : m_buffers) + { + const String& name = buffer->name(); + if (boost::regex_search(name.begin(), name.end(), ex)) + result.push_back(name); + } + } return result; }