fix(ui): special handling for floats closed before VimEnter. Seems that WinClosed events dont execute before that. Fixes #1390

This commit is contained in:
Folke Lemaitre 2024-03-27 08:48:55 +01:00
parent d37a76b871
commit eefb8974d6
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040
3 changed files with 89 additions and 26 deletions

View file

@ -53,7 +53,7 @@ function M.create()
Float.init(self, {
title = Config.options.ui.title,
title_pos = Config.options.ui.title_pos,
noautocmd = true,
noautocmd = false,
})
if Config.options.ui.wrap then
@ -69,12 +69,14 @@ function M.create()
self.render = Render.new(self)
self.update = Util.throttle(Config.options.ui.throttle, self.update)
self:on({ "User LazyRender", "User LazyFloatResized" }, function()
if not (self.buf and vim.api.nvim_buf_is_valid(self.buf)) then
return true
end
self:update()
end)
for _, pattern in ipairs({ "LazyRender", "LazyFloatResized" }) do
self:on({ "User" }, function()
if not (self.buf and vim.api.nvim_buf_is_valid(self.buf)) then
return true
end
self:update()
end, { pattern = pattern })
end
vim.keymap.set("n", ViewConfig.keys.abort, function()
require("lazy.manage.process").abort()