@@ -31,6 +31,7 @@ local menu = {
31
31
}),
32
32
items = {},
33
33
context = nil ,
34
+ auto_show = config .auto_show ,
34
35
open_emitter = require (' blink.cmp.lib.event_emitter' ).new (' completion_menu_open' , ' BlinkCmpCompletionMenuOpen' ),
35
36
close_emitter = require (' blink.cmp.lib.event_emitter' ).new (' completion_menu_close' , ' BlinkCmpCompletionMenuClose' ),
36
37
position_update_emitter = require (' blink.cmp.lib.event_emitter' ).new (
@@ -43,8 +44,6 @@ vim.api.nvim_create_autocmd({ 'CursorMovedI', 'WinScrolled', 'WinResized' }, {
43
44
callback = function () menu .update_position () end ,
44
45
})
45
46
46
- --- @param context blink.cmp.Context
47
- --- @param items blink.cmp.CompletionItem[]
48
47
function menu .open_with_items (context , items )
49
48
menu .context = context
50
49
menu .items = items
@@ -53,12 +52,7 @@ function menu.open_with_items(context, items)
53
52
if not menu .renderer then menu .renderer = require (' blink.cmp.completion.windows.render' ).new (config .draw ) end
54
53
menu .renderer :draw (menu .win :get_buf (), items )
55
54
56
- menu .open ()
57
- menu .update_position ()
58
-
59
- -- it's possible for the window to close after updating the position
60
- -- if there was nowhere to place the window
61
- if not menu .win :is_open () then return end
55
+ if menu .auto_show then menu .open () end
62
56
end
63
57
64
58
function menu .open ()
@@ -68,11 +62,13 @@ function menu.open()
68
62
if menu .selected_item_idx ~= nil then
69
63
vim .api .nvim_win_set_cursor (menu .win :get_win (), { menu .selected_item_idx , 0 })
70
64
end
65
+ menu .update_position ()
71
66
72
67
menu .open_emitter :emit ()
73
68
end
74
69
75
70
function menu .close ()
71
+ menu .auto_show = config .auto_show
76
72
if not menu .win :is_open () then return end
77
73
78
74
menu .win :close ()
0 commit comments