fix: confirm before deleting buffers/workspaces

This commit is contained in:
əlemi 2024-09-15 12:10:19 +02:00
parent b4b2e208f8
commit a0c1fb3acd
Signed by: alemi
GPG key ID: A4895B84D311642C

View file

@ -76,22 +76,28 @@ M.delete = function(state, path, extra)
if selected.type == "root" and vim.startswith(selected.name, "#") then
vim.ui.input({ prompt = "disconnect from workspace?" }, function (input)
if input == nil then return end
if input ~= "y" then return end
if not vim.startswith("y", string.lower(input)) then return end
ws_manager.leave()
manager.refresh("codemp")
end)
elseif selected.type == "buffer" then
if session.workspace == nil then error("join a workspace first") end
session.workspace:delete_buffer(selected.name):await()
print("deleted buffer " .. selected.name)
manager.refresh("codemp")
vim.ui.input({ prompt = "delete buffer '" .. selected.name .. "'?" }, function (input)
if input == nil then return end
if not vim.startswith("y", string.lower(input)) then return end
session.workspace:delete_buffer(selected.name):await()
print("deleted buffer " .. selected.name)
manager.refresh("codemp")
end)
elseif selected.type == "workspace" then
if session.client == nil then error("connect to server first") end
session.client:delete_workspace(selected.name):await()
print("deleted workspace " .. selected.name)
manager.refresh("codemp")
else
print("/!\\ can only delete buffers and workspaces")
vim.ui.input({ prompt = "delete buffer '" .. selected.name .. "'?" }, function (input)
if input == nil then return end
if not vim.startswith("y", string.lower(input)) then return end
session.client:delete_workspace(selected.name):await()
print("deleted workspace " .. selected.name)
manager.refresh("codemp")
end)
end
end