Skip to content

Commit 0a06828

Browse files
committed
fix(buffer): deduplicate words globally
Closes #1789
1 parent 9873411 commit 0a06828

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lua/blink/cmp/sources/buffer.lua

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ local function run_async_lua(buf_text, callback)
7272

7373
local cancelled = false
7474
local pos = 1
75+
local all_words = {}
76+
7577
local function next_chunk()
7678
if cancelled then return end
7779

@@ -93,11 +95,13 @@ local function run_async_lua(buf_text, callback)
9395

9496
local chunk_text = string.sub(buf_text, start_pos, end_pos)
9597
local chunk_words = require('blink.cmp.fuzzy').get_words(chunk_text)
96-
local words = require('blink.cmp.lib.utils').deduplicate(chunk_words)
98+
vim.list_extend(all_words, chunk_words)
9799

98100
-- next iter
99101
if pos < total_length then return vim.schedule(next_chunk) end
100-
-- or finish
102+
103+
-- Deduplicate and finish
104+
local words = require('blink.cmp.lib.utils').deduplicate(all_words)
101105
vim.schedule(function() callback(words_to_items(words)) end)
102106
end
103107

0 commit comments

Comments
 (0)