mirror of
https://github.com/folke/snacks.nvim
synced 2025-08-04 10:49:08 +00:00
perf(util): redraw helpers
This commit is contained in:
parent
cdb495cb8f
commit
9fb88c67b6
1 changed files with 24 additions and 0 deletions
|
@ -124,4 +124,28 @@ function M.is_transparent()
|
|||
return transparent
|
||||
end
|
||||
|
||||
--- Redraw the range of lines in the window.
|
||||
--- Optimized for Neovim >= 0.10
|
||||
---@param win number
|
||||
---@param from number -- 1-indexed, inclusive
|
||||
---@param to number -- 1-indexed, inclusive
|
||||
function M.redraw_range(win, from, to)
|
||||
if vim.api.nvim__redraw then
|
||||
vim.api.nvim__redraw({ win = win, range = { math.floor(from - 1), math.floor(to) }, valid = true, flush = false })
|
||||
else
|
||||
vim.cmd([[redraw!]])
|
||||
end
|
||||
end
|
||||
|
||||
--- Redraw the window.
|
||||
--- Optimized for Neovim >= 0.10
|
||||
---@param win number
|
||||
function M.redraw(win)
|
||||
if vim.api.nvim__redraw then
|
||||
vim.api.nvim__redraw({ win = win, valid = false, flush = false })
|
||||
else
|
||||
vim.cmd([[redraw!]])
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue