diff options
| author | Maxime Coste <mawww@kakoune.org> | 2017-11-25 13:47:04 +0800 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2017-11-25 13:57:47 +0800 |
| commit | ec6ecd57725af15f557d3409114e0698a13cee6c (patch) | |
| tree | 09f70369c7de750d8ae0e6d91128e2c483eb779f /src | |
| parent | 1ae96c977c5c205423f19b5fdb4c01ba76f68b12 (diff) | |
Add an InsertCompletionSelect hook
InsertCompletionSelect will be called whenever the selected insert
completion changes. If the original text is selected back, the hook
parameter will be empty. If another candidate is selected, the hook
parameter will be its text content.
Fixes #1676
Diffstat (limited to 'src')
| -rw-r--r-- | src/commands.cc | 2 | ||||
| -rw-r--r-- | src/insert_completer.cc | 7 |
2 files changed, 8 insertions, 1 deletions
diff --git a/src/commands.cc b/src/commands.cc index 1a8e8f73..8ae74c7c 100644 --- a/src/commands.cc +++ b/src/commands.cc @@ -752,7 +752,7 @@ static constexpr auto hooks = { "BufCreate", "BufNewFile", "BufOpenFile", "BufClose", "BufWritePost", "BufWritePre", "BufOpenFifo", "BufCloseFifo", "BufReadFifo", "BufSetOption", "InsertBegin", "InsertChar", "InsertDelete", "InsertEnd", "InsertIdle", "InsertKey", - "InsertMove", "InsertCompletionHide", "InsertCompletionShow", + "InsertMove", "InsertCompletionHide", "InsertCompletionShow", "InsertCompletionSelect", "KakBegin", "KakEnd", "FocusIn", "FocusOut", "RuntimeError", "PromptIdle", "NormalBegin", "NormalEnd", "NormalIdle", "NormalKey", "RawKey", "WinClose", "WinCreate", "WinDisplay", "WinResize", "WinSetOption", diff --git a/src/insert_completer.cc b/src/insert_completer.cc index d8730f70..4a4e9be0 100644 --- a/src/insert_completer.cc +++ b/src/insert_completer.cc @@ -425,6 +425,13 @@ void InsertCompleter::select(int offset, Vector<Key>& keystrokes) keystrokes.emplace_back(Key::Delete); for (auto& c : candidate.completion) keystrokes.emplace_back(c); + + if (m_context.has_client()) + { + const auto param = (m_current_candidate == m_completions.candidates.size() - 1) ? + StringView{} : candidate.completion; + m_context.hooks().run_hook("InsertCompletionSelect", param, m_context); + } } void InsertCompleter::update() |
