fix(toggle): Restore width/height values when closing while maximized is toggled on (#3453)

This commit is contained in:
Iordanis Petkakis 2024-06-05 07:54:52 +03:00 committed by GitHub
parent 987bd2207f
commit 8971ea25f9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -88,6 +88,17 @@ function M.maximize()
vim.o.winwidth = 999 vim.o.winwidth = 999
vim.o.winheight = 999 vim.o.winheight = 999
end end
-- `QuitPre` seems to be executed even if we quit a normal window, so we don't want that
-- `VimLeavePre` might be another consideration? Not sure about differences between the 2
vim.api.nvim_create_autocmd("ExitPre", {
once = true,
group = vim.api.nvim_create_augroup("lazyvim_restore_max_exit_pre", { clear = true }),
desc = "Restore width/height when close Neovim while maximized",
callback = function()
vim.o.winwidth = M._maximized.width
vim.o.winheight = M._maximized.height
end,
})
end end
setmetatable(M, { setmetatable(M, {