From 73e438be07d4a7623e52419674bef4d1bc8dcb21 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Mon, 19 Oct 2015 13:43:23 +0100 Subject: [PATCH] Fix handling of explicit insert completers --- src/insert_completer.cc | 17 +++++++++++++---- 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& 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(buffer, cursor_pos, m_options); - }); + }; + try_complete(func); + m_explicit_completer = func; } void InsertCompleter::explicit_word_complete() { try_complete(complete_word); + m_explicit_completer = complete_word; } 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 m_explicit_completer; }; }