mirror of
https://github.com/folke/snacks.nvim
synced 2025-12-23 08:47:57 +00:00
fix(dashboard): work-around for jobstart+pty issue where not all output is processed before exit. Closes #1706
This commit is contained in:
parent
a2c1e69245
commit
4d776bdd1d
1 changed files with 8 additions and 2 deletions
|
|
@ -551,7 +551,7 @@ end
|
||||||
---@param cb fun()
|
---@param cb fun()
|
||||||
---@param group? string|integer
|
---@param group? string|integer
|
||||||
function D.on(event, cb, group)
|
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
|
end
|
||||||
|
|
||||||
---@param pos {[1]:number, [2]:number}
|
---@param pos {[1]:number, [2]:number}
|
||||||
|
|
@ -951,6 +951,12 @@ end
|
||||||
function M.sections.terminal(opts)
|
function M.sections.terminal(opts)
|
||||||
return function(self)
|
return function(self)
|
||||||
local cmd = opts.cmd or 'echo "No `cmd` provided"'
|
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 ttl = opts.ttl or 3600
|
||||||
local height = opts.height or 10
|
local height = opts.height or 10
|
||||||
local width = opts.width
|
local width = opts.width
|
||||||
|
|
@ -1026,7 +1032,7 @@ function M.sections.terminal(opts)
|
||||||
end
|
end
|
||||||
if first and has_cache then -- clear the screen if cache was expired
|
if first and has_cache then -- clear the screen if cache was expired
|
||||||
first = false
|
first = false
|
||||||
data = "\27[2J\27[H" .. data -- clear screen
|
send("\27[H\27[2J") -- clear screen
|
||||||
end
|
end
|
||||||
pcall(send, data)
|
pcall(send, data)
|
||||||
end,
|
end,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue