aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-01-11 10:45:46 +0800
committerzeertzjq <zeertzjq@outlook.com>2022-01-11 13:59:39 +0800
commitc7aa64631d721d140741206167d9a6ce766f1153 (patch)
tree2d87f455c11fc131b02f23626c822a149c5ae792 /src
parent7165e7770df581179fabf8fd03109909c6be879a (diff)
downloadrneovim-c7aa64631d721d140741206167d9a6ce766f1153.tar.gz
rneovim-c7aa64631d721d140741206167d9a6ce766f1153.tar.bz2
rneovim-c7aa64631d721d140741206167d9a6ce766f1153.zip
feat(completion): support selecting item via API from Lua mapping
Diffstat (limited to 'src')
-rw-r--r--src/nvim/edit.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/nvim/edit.c b/src/nvim/edit.c
index aa37d1b2dd..9efe5a27c4 100644
--- a/src/nvim/edit.c
+++ b/src/nvim/edit.c
@@ -1082,6 +1082,8 @@ static int insert_handle_key(InsertState *s)
map_execute_lua();
check_pum:
+ // nvim_select_popupmenu_item() can be called from the handling of
+ // K_EVENT, K_COMMAND, or K_LUA.
// TODO(bfredl): Not entirely sure this indirection is necessary
// but doing like this ensures using nvim_select_popupmenu_item is
// equivalent to selecting the item with a typed key.
@@ -4986,7 +4988,7 @@ void ins_compl_check_keys(int frequency, int in_compl_func)
*/
static int ins_compl_key2dir(int c)
{
- if (c == K_EVENT || c == K_COMMAND) {
+ if (c == K_EVENT || c == K_COMMAND || c == K_LUA) {
return pum_want.item < pum_selected_item ? BACKWARD : FORWARD;
}
if (c == Ctrl_P || c == Ctrl_L
@@ -5016,7 +5018,7 @@ static int ins_compl_key2count(int c)
{
int h;
- if (c == K_EVENT || c == K_COMMAND) {
+ if (c == K_EVENT || c == K_COMMAND || c == K_LUA) {
int offset = pum_want.item - pum_selected_item;
return abs(offset);
}
@@ -5050,6 +5052,7 @@ static bool ins_compl_use_match(int c)
return false;
case K_EVENT:
case K_COMMAND:
+ case K_LUA:
return pum_want.active && pum_want.insert;
}
return true;