perf(picker.lines): no need to run in async context

This commit is contained in:
Folke Lemaitre 2025-01-14 11:55:45 +01:00
parent 3bc227f5ad
commit ee322226af
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040

View file

@ -10,21 +10,18 @@ function M.lines(opts)
buf = buf == 0 and vim.api.nvim_get_current_buf() or buf
local extmarks = require("snacks.picker.util.highlight").get_highlights({ buf = buf })
local lines = vim.api.nvim_buf_get_lines(buf, 0, -1, false)
---@async
---@param cb async fun(item: snacks.picker.finder.Item)
return function(cb)
for l, line in ipairs(lines) do
---@type snacks.picker.finder.Item
local item = {
buf = buf,
text = line,
pos = { l, 0 },
highlights = extmarks[l],
}
cb(item)
end
local items = {} ---@type snacks.picker.finder.Item[]
for l, line in ipairs(lines) do
---@type snacks.picker.finder.Item
local item = {
buf = buf,
text = line,
pos = { l, 0 },
highlights = extmarks[l],
}
items[#items + 1] = item
end
return items
end
return M