Skip to content

Commit 632e6ac

Browse files
committed
fix: avoid immediately showing on context change
1 parent 3f1c8bd commit 632e6ac

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

lua/blink/cmp/init.lua

+8-2
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,18 @@ cmp.setup = function(opts)
3737
-- we store the previous items so we can immediately perform fuzzy matching on keystroke
3838
-- and then update again when the sources return new results
3939
local last_items = {}
40+
local last_context = nil
4041
local function update_completions(context, items)
41-
if items == nil then items = last_items end
42+
if items == nil then
43+
if last_context == nil or last_context.id ~= context.id then return end
44+
items = last_items
45+
end
46+
last_context = context
4247
last_items = items
48+
4349
-- we avoid adding 1-4ms to insertion latency by scheduling for later
4450
vim.schedule(function()
45-
local filtered_items = cmp.fuzzy.filter_items(require('blink.cmp.util').get_query(), items)
51+
local filtered_items = cmp.fuzzy.filter_items(require('blink.cmp.utils').get_query(), items)
4652
if #filtered_items > 0 then
4753
cmp.windows.autocomplete.open_with_items(context, filtered_items)
4854
else

0 commit comments

Comments
 (0)