diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2014-03-19 08:05:28 +0000 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2014-03-19 08:05:28 +0000 |
| commit | 0db39ccfd0a21cc8493a78fd4d7089b2a5368135 (patch) | |
| tree | c6dcd64f97431a4b80677b84e09144dac7ce7011 /src/input_handler.cc | |
| parent | dc087b3b7c680860711c9480d118b7469c8f5a8b (diff) | |
Automatic insert filename completion kicks in only if prefix contains slash
Diffstat (limited to 'src/input_handler.cc')
| -rw-r--r-- | src/input_handler.cc | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/input_handler.cc b/src/input_handler.cc index 8b8582f8..f275af23 100644 --- a/src/input_handler.cc +++ b/src/input_handler.cc @@ -787,6 +787,7 @@ public: return { begin.coord(), end.coord(), std::move(result), buffer.timestamp() }; } + template<bool require_slash> BufferCompletion complete_filename(const Buffer& buffer, BufferCoord cursor_pos) { auto pos = buffer.iterator_at(cursor_pos); @@ -803,6 +804,9 @@ public: return {}; String prefix{begin, pos}; + if (require_slash and not contains(prefix, '/')) + return {}; + StringList res; if (prefix.front() == '/') res = Kakoune::complete_filename(prefix, Regex{}); @@ -913,7 +917,7 @@ private: { if (completer == "filename" and try_complete([this](const Buffer& buffer, BufferCoord cursor_pos) - { return complete_filename(buffer, cursor_pos); })) + { return complete_filename<true>(buffer, cursor_pos); })) return true; if (completer.substr(0_byte, 7_byte) == "option=" and try_complete([&, this](const Buffer& buffer, BufferCoord cursor_pos) @@ -974,7 +978,7 @@ public: { if (key.key == 'f') m_completer.try_complete([this](const Buffer& buffer, BufferCoord cursor_pos) - { return m_completer.complete_filename(buffer, cursor_pos); }); + { return m_completer.complete_filename<false>(buffer, cursor_pos); }); if (key.key == 'w') m_completer.try_complete([this](const Buffer& buffer, BufferCoord cursor_pos) { return m_completer.complete_word<true>(buffer, cursor_pos); }); |
