From 8971ea25f953f778c8db999da4de240a07713aaa Mon Sep 17 00:00:00 2001 From: Iordanis Petkakis <12776461+dpetka2001@users.noreply.github.com> Date: Wed, 5 Jun 2024 07:54:52 +0300 Subject: [PATCH] fix(toggle): Restore width/height values when closing while maximized is toggled on (#3453) --- lua/lazyvim/util/toggle.lua | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lua/lazyvim/util/toggle.lua b/lua/lazyvim/util/toggle.lua index b001798f..c0dce716 100644 --- a/lua/lazyvim/util/toggle.lua +++ b/lua/lazyvim/util/toggle.lua @@ -88,6 +88,17 @@ function M.maximize() vim.o.winwidth = 999 vim.o.winheight = 999 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 setmetatable(M, {