mirror of
https://github.com/folke/snacks.nvim
synced 2025-08-04 18:58:12 +00:00
perf(picker.lines): no need to run in async context
This commit is contained in:
parent
3bc227f5ad
commit
ee322226af
1 changed files with 11 additions and 14 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue