Skip to content

Commit

Permalink
fix: shallow copy luasnip items
Browse files Browse the repository at this point in the history
Closes #1006
  • Loading branch information
Saghen committed Jan 19, 2025
1 parent 2144c58 commit 712af9f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lua/blink/cmp/sources/snippets/luasnip.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
--- @field config blink.cmp.LuasnipSourceOptions
--- @field items_cache table<string, blink.cmp.CompletionItem[]>

local utils = require('blink.cmp.lib.utils')

--- @type blink.cmp.LuasnipSource
--- @diagnostic disable-next-line: missing-fields
local source = {}
Expand Down Expand Up @@ -55,6 +57,9 @@ function source:get_completions(ctx, callback)
-- gather snippets from relevant filetypes, including extensions
for _, ft in ipairs(require('luasnip.util.util').get_snippet_filetypes()) do
if self.items_cache[ft] then
for _, item in ipairs(self.items_cache[ft]) do
table.insert(items, utils.shallow_copy(item))
end
vim.list_extend(items, self.items_cache[ft])
goto continue
end
Expand Down Expand Up @@ -94,7 +99,7 @@ function source:get_completions(ctx, callback)
-- populate snippet cache for this filetype
table.insert(self.items_cache[ft], item)
-- while we're at it, also populate completion items for this request
table.insert(items, item)
table.insert(items, utils.shallow_copy(item))
end

::continue::
Expand Down

0 comments on commit 712af9f

Please sign in to comment.