mirror of
https://github.com/folke/snacks.nvim
synced 2025-08-04 10:49:08 +00:00
fix(image): delay sending first image, to make ghostty happy. Closes #1333
This commit is contained in:
parent
5a2acf82b2
commit
9aa8cbb803
1 changed files with 20 additions and 2 deletions
|
@ -51,6 +51,16 @@ vim.api.nvim_create_autocmd("VimResized", {
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
-- HACK: ghostty doesn't like it when sending images too fast,
|
||||||
|
-- after Neovim startup, so we delay the first image
|
||||||
|
local queue = {} ---@type string[]?
|
||||||
|
vim.defer_fn(function()
|
||||||
|
if queue and #queue > 0 then
|
||||||
|
io.stdout:write(table.concat(queue, ""))
|
||||||
|
queue = nil
|
||||||
|
end
|
||||||
|
end, 100)
|
||||||
|
|
||||||
function M.size()
|
function M.size()
|
||||||
if size then
|
if size then
|
||||||
return size
|
return size
|
||||||
|
@ -172,12 +182,20 @@ function M.request(opts)
|
||||||
if Snacks.image.config.debug.request and opts.m ~= 1 then
|
if Snacks.image.config.debug.request and opts.m ~= 1 then
|
||||||
Snacks.debug.inspect(opts)
|
Snacks.debug.inspect(opts)
|
||||||
end
|
end
|
||||||
io.stdout:write(data)
|
M.write(data)
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param pos {[1]: number, [2]: number}
|
---@param pos {[1]: number, [2]: number}
|
||||||
function M.set_cursor(pos)
|
function M.set_cursor(pos)
|
||||||
io.stdout:write("\27[" .. pos[1] .. ";" .. (pos[2] + 1) .. "H")
|
M.write("\27[" .. pos[1] .. ";" .. (pos[2] + 1) .. "H")
|
||||||
|
end
|
||||||
|
|
||||||
|
function M.write(data)
|
||||||
|
if queue then
|
||||||
|
table.insert(queue, data)
|
||||||
|
else
|
||||||
|
io.stdout:write(data)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue