fix(dashboard): work-around for jobstart+pty issue where not all output is processed before exit. Closes #1706

This commit is contained in:
Folke Lemaitre 2025-10-24 23:25:26 +02:00
parent a2c1e69245
commit 4d776bdd1d
No known key found for this signature in database
GPG key ID: 9B52594D560070AB

View file

@ -551,7 +551,7 @@ end
---@param cb fun()
---@param group? string|integer
function D.on(event, cb, group)
vim.api.nvim_create_autocmd("User", { pattern = "SnacksDashboard" .. event, callback = cb, group = group })
return vim.api.nvim_create_autocmd("User", { pattern = "SnacksDashboard" .. event, callback = cb, group = group })
end
---@param pos {[1]:number, [2]:number}
@ -951,6 +951,12 @@ end
function M.sections.terminal(opts)
return function(self)
local cmd = opts.cmd or 'echo "No `cmd` provided"'
if type(cmd) == "string" and vim.fn.has("linux") == 1 then
-- work-around for https://github.com/folke/snacks.nvim/issues/1706
-- jobstart+pty sometimes doesn't flush the full output before exiting
cmd = cmd .. "; sleep .1"
end
local ttl = opts.ttl or 3600
local height = opts.height or 10
local width = opts.width
@ -1026,7 +1032,7 @@ function M.sections.terminal(opts)
end
if first and has_cache then -- clear the screen if cache was expired
first = false
data = "\27[2J\27[H" .. data -- clear screen
send("\27[H\27[2J") -- clear screen
end
pcall(send, data)
end,