diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2015-10-19 13:43:23 +0100 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2015-10-19 13:43:23 +0100 |
| commit | 73e438be07d4a7623e52419674bef4d1bc8dcb21 (patch) | |
| tree | 7fddd17bbea6ed4bba0604c26810b4fe1d5c84eb /src | |
| parent | 364914afbd3da050d021dceee02d4c89e78b9d52 (diff) | |
Fix handling of explicit insert completers
Diffstat (limited to 'src')
| -rw-r--r-- | src/insert_completer.cc | 17 | ||||
| -rw-r--r-- | src/insert_completer.hh | 2 |
2 files changed, 15 insertions, 4 deletions
diff --git a/src/insert_completer.cc b/src/insert_completer.cc index f81c47c3..214e8f25 100644 --- a/src/insert_completer.cc +++ b/src/insert_completer.cc @@ -350,6 +350,9 @@ void InsertCompleter::select(int offset, Vector<Key>& keystrokes) void InsertCompleter::update() { + if (m_explicit_completer and try_complete(m_explicit_completer)) + return; + reset(); setup_ifn(); } @@ -357,6 +360,7 @@ void InsertCompleter::update() void InsertCompleter::reset() { m_completions = InsertCompletion{}; + m_explicit_completer = nullptr; if (m_context.has_ui()) { m_context.ui().menu_hide(); @@ -462,21 +466,26 @@ bool InsertCompleter::try_complete(CompleteFunc complete_func) void InsertCompleter::explicit_file_complete() { - try_complete([this](const Buffer& buffer, ByteCoord cursor_pos) { + auto func = [this](const Buffer& buffer, ByteCoord cursor_pos) { return complete_filename<false>(buffer, cursor_pos, m_options); - }); + }; + try_complete(func); + m_explicit_completer = func; } void InsertCompleter::explicit_word_complete() { try_complete(complete_word<true>); + m_explicit_completer = complete_word<true>; } void InsertCompleter::explicit_line_complete() { - try_complete([this](const Buffer& buffer, ByteCoord cursor_pos) { + auto func = [this](const Buffer& buffer, ByteCoord cursor_pos) { return complete_line(buffer, m_options, cursor_pos); - }); + }; + try_complete(func); + m_explicit_completer = func; } } diff --git a/src/insert_completer.hh b/src/insert_completer.hh index 650fbf69..5aeade49 100644 --- a/src/insert_completer.hh +++ b/src/insert_completer.hh @@ -89,6 +89,8 @@ private: InsertCompletion m_completions; CandidateList m_matching_candidates; int m_current_candidate = -1; + + std::function<InsertCompletion (const Buffer&, ByteCoord)> m_explicit_completer; }; } |
