summaryrefslogtreecommitdiff
path: root/src/buffer_manager.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/buffer_manager.cc')
-rw-r--r--src/buffer_manager.cc13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/buffer_manager.cc b/src/buffer_manager.cc
index 5f3fe1ec..77e1d66e 100644
--- a/src/buffer_manager.cc
+++ b/src/buffer_manager.cc
@@ -99,14 +99,23 @@ CandidateList BufferManager::complete_buffername(const String& prefix,
ByteCount cursor_pos)
{
String real_prefix = prefix.substr(0, cursor_pos);
+ const bool include_dirs = contains(real_prefix, '/');
CandidateList result;
CandidateList subsequence_result;
for (auto& buffer : m_buffers)
{
String name = buffer->display_name();
- if (prefix_match(name, real_prefix))
+ String match_name = name;
+ if (not include_dirs and buffer->flags() & Buffer::Flags::File)
+ {
+ ByteCount pos = name.find_last_of('/');
+ if (pos != String::npos)
+ match_name = name.substr(pos);
+ }
+
+ if (prefix_match(match_name, real_prefix))
result.push_back(escape(name));
- if (subsequence_match(name, real_prefix))
+ if (subsequence_match(match_name, real_prefix))
subsequence_result.push_back(escape(name));
}
return result.empty() ? subsequence_result : result;