feat(image): show progress indicator when converting image files

This commit is contained in:
Folke Lemaitre 2025-02-17 23:56:55 +01:00
parent 8d073ccc0c
commit b65178b470
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040
9 changed files with 108 additions and 33 deletions

View file

@ -6,7 +6,6 @@
local M = {}
M.__index = M
local uv = vim.uv or vim.loop
local ns = vim.api.nvim_create_namespace("snacks.picker.input")
---@param picker snacks.Picker
@ -144,7 +143,7 @@ function M:update()
end
local line = {} ---@type snacks.picker.Highlight[]
if self.picker:is_active() then
line[#line + 1] = { M.spinner(), "SnacksPickerSpinner" }
line[#line + 1] = { Snacks.util.spinner(), "SnacksPickerSpinner" }
line[#line + 1] = { " " }
end
local selected = #self.picker.list.selected
@ -188,9 +187,4 @@ function M:set(pattern, search)
self.picker:update_titles()
end
function M.spinner()
local spinner = { "", "", "", "", "", "", "", "", "", "" }
return spinner[math.floor(uv.hrtime() / (1e6 * 80)) % #spinner + 1]
end
return M

View file

@ -182,7 +182,9 @@ function M.cmd(cmd, ctx, opts)
if ctx.picker.opts.debug.proc then
local args = vim.deepcopy(cmd)
table.remove(args, 1)
Snacks.debug.cmd({ cmd = cmd[1], args = args, cwd = ctx.item.cwd })
vim.schedule(function()
Snacks.debug.cmd({ cmd = cmd[1], args = args, cwd = ctx.item.cwd })
end)
end
---@param text string

View file

@ -40,7 +40,9 @@ function M.proc(opts, ctx)
end
if ctx.picker.opts.debug.proc then
Snacks.debug.cmd(Snacks.config.merge(opts, { group = true }))
vim.schedule(function()
Snacks.debug.cmd(Snacks.config.merge(opts, { group = true }))
end)
end
local sep = opts.sep or "\n"