Skip to content

Commit adf2e05

Browse files
committed
refactor: simplify autocmd unsubscription
1 parent 9aa0b79 commit adf2e05

File tree

1 file changed

+2
-13
lines changed

1 file changed

+2
-13
lines changed

lua/overseer/layout.lua

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -160,22 +160,11 @@ M.open_fullscreen_float = function(bufnr)
160160
end,
161161
})
162162

163-
local augroup_name = "OverseerFloatResize_" .. winid
164-
vim.api.nvim_create_augroup(augroup_name, { clear = true })
165-
vim.api.nvim_create_autocmd("WinClosed", {
166-
desc = "Clean up auto commands when window is closed",
167-
group = augroup_name,
168-
callback = function(args)
169-
if args.match == tostring(winid) then
170-
pcall(vim.api.nvim_del_augroup_by_name, augroup_name)
171-
end
172-
end,
173-
})
174163
vim.api.nvim_create_autocmd("VimResized", {
175164
desc = "Resize floating window on VimResized",
176-
group = augroup_name,
177165
callback = function()
178-
pcall(vim.api.nvim_win_set_config, winid, get_dimensions())
166+
local win_exists = pcall(vim.api.nvim_win_set_config, winid, get_dimensions())
167+
return not win_exists
179168
end,
180169
})
181170

0 commit comments

Comments
 (0)