diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2013-09-25 18:59:03 +0100 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2013-09-25 18:59:03 +0100 |
| commit | b080f456a71d32037a4122d8c0742bfb26898c1b (patch) | |
| tree | 7684939f0b7355c1e753f25451bfde03f522298e /src/buffer_manager.cc | |
| parent | 60f4e1104f51a1984bb18a05d6958f46e1b50063 (diff) | |
Do not take directories into account when completing buffer name
(except if a / is found in the completion prefix)
Diffstat (limited to 'src/buffer_manager.cc')
| -rw-r--r-- | src/buffer_manager.cc | 13 |
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; |
