mirror of
https://github.com/folke/snacks.nvim
synced 2025-12-23 08:47:57 +00:00
perf(notifier): only force redraw for new windows and for updated while search is not active. Fixes #52
This commit is contained in:
parent
df8c9d7724
commit
da86b1deff
1 changed files with 18 additions and 3 deletions
|
|
@ -574,7 +574,8 @@ end
|
|||
|
||||
function N:layout()
|
||||
local layout = self:new_layout()
|
||||
local changes = 0
|
||||
local wins_updated = 0
|
||||
local wins_created = 0
|
||||
for _, notif in ipairs(assert(self.sorted)) do
|
||||
if layout.free < (self.opts.height.min + 2) then -- not enough space
|
||||
if notif.win then
|
||||
|
|
@ -595,7 +596,11 @@ function N:layout()
|
|||
if notif.layout.top then
|
||||
layout.mark(notif.layout.top, notif.layout.height, false)
|
||||
if not vim.deep_equal(prev_layout, notif.layout) then
|
||||
changes = changes + 1
|
||||
if notif.win:win_valid() then
|
||||
wins_updated = wins_updated + 1
|
||||
else
|
||||
wins_created = wins_created + 1
|
||||
end
|
||||
notif.win.opts.row = notif.layout.top - 1
|
||||
notif.win.opts.col = vim.o.columns - notif.layout.width - self.opts.margin.right
|
||||
notif.shown = notif.shown or ts()
|
||||
|
|
@ -604,7 +609,17 @@ function N:layout()
|
|||
end
|
||||
end
|
||||
end
|
||||
return changes > 0 and (vim.cmd.redraw() or true)
|
||||
|
||||
local redraw = false
|
||||
or wins_created > 0 -- always redraw when new windows are created
|
||||
or (
|
||||
wins_updated > 0 -- only redraw updated windows when not searching
|
||||
and not (vim.tbl_contains({ "/", "?" }, vim.fn.getcmdtype()))
|
||||
)
|
||||
|
||||
if redraw then
|
||||
vim.cmd.redraw()
|
||||
end
|
||||
end
|
||||
|
||||
---@param msg string
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue