Skip to content

Commit 624676e

Browse files
committed
fix: documentation window auto show once and for all
Closes #430
1 parent 51d5f59 commit 624676e

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

lua/blink/cmp/completion/init.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ function completion.setup()
4242
list.hide_emitter:on(function() require('blink.cmp.completion.windows.menu').close() end)
4343
list.select_emitter:on(function(event)
4444
require('blink.cmp.completion.windows.menu').set_selected_item_idx(event.idx)
45-
require('blink.cmp.completion.windows.documentation').auto_show_item(event.context, event.item)
45+
require('blink.cmp.completion.windows.documentation').auto_show_item(event.item)
4646
end)
4747
end
4848

lua/blink/cmp/completion/windows/documentation.lua

+7-6
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
--- @field auto_show_timer uv_timer_t
55
--- @field shown_item? blink.cmp.CompletionItem
66
---
7-
--- @field auto_show_item fun(context: blink.cmp.Context, item: blink.cmp.CompletionItem)
7+
--- @field auto_show_item fun(item: blink.cmp.CompletionItem)
88
--- @field show_item fun(item: blink.cmp.CompletionItem)
99
--- @field update_position fun()
1010
--- @field scroll_up fun(amount: number)
@@ -35,18 +35,19 @@ local docs = {
3535
}
3636

3737
menu.position_update_emitter:on(docs.update_position)
38-
menu.close_emitter:on(function() docs.win:close() end)
38+
menu.close_emitter:on(function()
39+
docs.win:close()
40+
docs.auto_show_timer:stop()
41+
end)
3942

40-
function docs.auto_show_item(context, item)
43+
function docs.auto_show_item(item)
4144
docs.auto_show_timer:stop()
42-
if docs.win:is_open() or context.id == docs.last_context_id then
43-
docs.last_context_id = context.id
45+
if docs.win:is_open() then
4446
docs.auto_show_timer:start(config.update_delay_ms, 0, function()
4547
vim.schedule(function() docs.show_item(item) end)
4648
end)
4749
elseif config.auto_show then
4850
docs.auto_show_timer:start(config.auto_show_delay_ms, 0, function()
49-
docs.last_context_id = context.id
5051
vim.schedule(function() docs.show_item(item) end)
5152
end)
5253
end

0 commit comments

Comments
 (0)