fix(ui): closes ui when making projects and files

This commit is contained in:
DarthMooMancer
2025-07-20 02:27:24 -04:00
parent cf84fe2080
commit 66ae61f2c9
+13
View File
@@ -68,6 +68,16 @@ function M.manager(project_root)
Recents = nil, Recents = nil,
} }
local function close_all_windows()
for _, win in pairs(content_wins) do
if win and vim.api.nvim_win_is_valid(win) then
pcall(vim.api.nvim_win_close, win, true)
end
end
pcall(vim.api.nvim_win_close, tab_win, true)
end
local function update_tab_bar() local function update_tab_bar()
local line = {} local line = {}
for i, tab in ipairs(tabs) do for i, tab in ipairs(tabs) do
@@ -220,6 +230,7 @@ function M.manager(project_root)
if lang == nil or lang == "" then return print("Error: Lang cannot be nil") end if lang == nil or lang == "" then return print("Error: Lang cannot be nil") end
if templates.files[lang].run then if templates.files[lang].run then
if name ~= nil and name ~= "" then if name ~= nil and name ~= "" then
close_all_windows()
templates.files[lang].run(name) templates.files[lang].run(name)
end end
else else
@@ -231,6 +242,7 @@ function M.manager(project_root)
if lang == nil or lang == "" then return print("Error: Lang cannot be nil") end if lang == nil or lang == "" then return print("Error: Lang cannot be nil") end
if templates.extras.run then if templates.extras.run then
if name ~= nil and name ~= "" then if name ~= nil and name ~= "" then
close_all_windows()
templates.extras.run(lang, name) templates.extras.run(lang, name)
end end
else else
@@ -244,6 +256,7 @@ function M.manager(project_root)
if lang == nil or lang == "" then return print("Error: Lang cannot be nil") end if lang == nil or lang == "" then return print("Error: Lang cannot be nil") end
if templates.projects[lang].run then if templates.projects[lang].run then
if name ~= nil and name ~= "" then if name ~= nil and name ~= "" then
close_all_windows()
templates.projects[lang].run(name, opts.project_root) templates.projects[lang].run(name, opts.project_root)
end end
else else