+62
-2
lines changedFilter options
+62
-2
lines changed Original file line number Diff line number Diff line change
@@ -1082,6 +1082,8 @@ static int insert_handle_key(InsertState *s)
1082
1082
map_execute_lua();
1083
1083
1084
1084
check_pum:
1085
+
// nvim_select_popupmenu_item() can be called from the handling of
1086
+
// K_EVENT, K_COMMAND, or K_LUA.
1085
1087
// TODO(bfredl): Not entirely sure this indirection is necessary
1086
1088
// but doing like this ensures using nvim_select_popupmenu_item is
1087
1089
// equivalent to selecting the item with a typed key.
@@ -4986,7 +4988,7 @@ void ins_compl_check_keys(int frequency, int in_compl_func)
4986
4988
*/
4987
4989
static int ins_compl_key2dir(int c)
4988
4990
{
4989
-
if (c == K_EVENT || c == K_COMMAND) {
4991
+
if (c == K_EVENT || c == K_COMMAND || c == K_LUA) {
4990
4992
return pum_want.item < pum_selected_item ? BACKWARD : FORWARD;
4991
4993
}
4992
4994
if (c == Ctrl_P || c == Ctrl_L
@@ -5016,7 +5018,7 @@ static int ins_compl_key2count(int c)
5016
5018
{
5017
5019
int h;
5018
5020
5019
-
if (c == K_EVENT || c == K_COMMAND) {
5021
+
if (c == K_EVENT || c == K_COMMAND || c == K_LUA) {
5020
5022
int offset = pum_want.item - pum_selected_item;
5021
5023
return abs(offset);
5022
5024
}
@@ -5050,6 +5052,7 @@ static bool ins_compl_use_match(int c)
5050
5052
return false;
5051
5053
case K_EVENT:
5052
5054
case K_COMMAND:
5055
+
case K_LUA:
5053
5056
return pum_want.active && pum_want.insert;
5054
5057
}
5055
5058
return true;
Original file line number Diff line number Diff line change
@@ -10,6 +10,7 @@ local funcs = helpers.funcs
10
10
local get_pathsep = helpers.get_pathsep
11
11
local eq = helpers.eq
12
12
local pcall_err = helpers.pcall_err
13
+
local exec_lua = helpers.exec_lua
13
14
14
15
describe('ui/ext_popupmenu', function()
15
16
local screen
@@ -369,6 +370,62 @@ describe('ui/ext_popupmenu', function()
369
370
{1:~ }|
370
371
{2:-- INSERT --} |
371
372
]])
373
+
374
+
command('iunmap <f1>')
375
+
command('iunmap <f2>')
376
+
command('iunmap <f3>')
377
+
exec_lua([[
378
+
vim.keymap.set('i', '<f1>', function() vim.api.nvim_select_popupmenu_item(2, true, false, {}) end)
379
+
vim.keymap.set('i', '<f2>', function() vim.api.nvim_select_popupmenu_item(-1, false, false, {}) end)
380
+
vim.keymap.set('i', '<f3>', function() vim.api.nvim_select_popupmenu_item(1, false, true, {}) end)
381
+
]])
382
+
feed('<C-r>=TestComplete()<CR>')
383
+
screen:expect([[
384
+
|
385
+
foo^ |
386
+
{6:fo x the foo }{1: }|
387
+
{7:bar }{1: }|
388
+
{7:spam }{1: }|
389
+
{1:~ }|
390
+
{1:~ }|
391
+
{2:-- INSERT --} |
392
+
]])
393
+
394
+
feed('<f1>')
395
+
screen:expect([[
396
+
|
397
+
spam^ |
398
+
{7:fo x the foo }{1: }|
399
+
{7:bar }{1: }|
400
+
{6:spam }{1: }|
401
+
{1:~ }|
402
+
{1:~ }|
403
+
{2:-- INSERT --} |
404
+
]])
405
+
406
+
feed('<f2>')
407
+
screen:expect([[
408
+
|
409
+
spam^ |
410
+
{7:fo x the foo }{1: }|
411
+
{7:bar }{1: }|
412
+
{7:spam }{1: }|
413
+
{1:~ }|
414
+
{1:~ }|
415
+
{2:-- INSERT --} |
416
+
]])
417
+
418
+
feed('<f3>')
419
+
screen:expect([[
420
+
|
421
+
bar^ |
422
+
{1:~ }|
423
+
{1:~ }|
424
+
{1:~ }|
425
+
{1:~ }|
426
+
{1:~ }|
427
+
{2:-- INSERT --} |
428
+
]])
372
429
end)
373
430
374
431
local function source_complete_month()
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4