fix(picker.preview): fix
Some checks are pending
CI / ci (push) Waiting to run

This commit is contained in:
Folke Lemaitre 2025-10-28 10:29:02 +01:00
parent 758bbfa13a
commit e2c1c527e4
No known key found for this signature in database
GPG key ID: 9B52594D560070AB

View file

@ -11,6 +11,7 @@
---@field title? string
---@field split_layout? boolean
---@field opts? snacks.picker.previewers.Config
---@field _spinner? snacks.util.Spinner
local M = {}
M.__index = M
@ -164,6 +165,7 @@ function M:show(picker, opts)
self.item = item
self.filter = picker:filter()
self.pos = item and item.pos or nil
self:spinner(false)
if item then
local buf = self.win.buf
local ok, err = pcall(
@ -232,6 +234,7 @@ function M:reset()
end
vim.api.nvim_buf_clear_namespace(self.win.buf, -1, 0, -1)
self:set_title()
self:spinner(false)
vim.treesitter.stop(self.win.buf)
vim.bo[self.win.buf].modifiable = true
self:set_lines({})
@ -289,6 +292,10 @@ function M:highlight(opts)
end
end
function M:ns()
return ns
end
-- show the item location
function M:loc()
vim.api.nvim_buf_clear_namespace(self.win.buf, ns_loc, 0, -1)
@ -434,4 +441,18 @@ function M:markdown()
end
end
function M:spinner(enable)
if enable == false then
if self._spinner then
self._spinner:stop()
self._spinner = nil
end
return
end
assert(self.win:buf_valid(), "invalid buffer")
local ret = Snacks.picker.util.spinner(self.win.buf)
self._spinner = ret
return ret
end
return M