mirror of
https://github.com/mawww/kakoune.git
synced 2024-11-24 07:53:41 +03:00
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
This commit is contained in:
parent
1ae96c977c
commit
ec6ecd5772
@ -151,6 +151,11 @@ of the given *group*.
|
||||
*InsertCompletionHide*::
|
||||
Triggered when the insert completion menu gets hidden
|
||||
|
||||
*InsertCompletionSelect*::
|
||||
Triggered when an entry is selected in the insert completion
|
||||
menu. The filtering text is the selected completion text or
|
||||
the empty string if the original text was selected back.
|
||||
|
||||
*RawKey*::
|
||||
Triggered whenever a key is pressed by the user, the key is
|
||||
used for filtering.
|
||||
|
@ -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",
|
||||
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user