mirror of
https://github.com/hexedtech/codemp-nvim.git
synced 2024-11-22 07:24:52 +01:00
fix: always leave workspace before disconnecting
This commit is contained in:
parent
e0c1069939
commit
594330c721
3 changed files with 9 additions and 0 deletions
|
@ -80,6 +80,10 @@ local connected_actions = {
|
||||||
end,
|
end,
|
||||||
|
|
||||||
disconnect = function()
|
disconnect = function()
|
||||||
|
if CODEMP.workspace ~= nil then
|
||||||
|
print(" xx leaving workspace " .. CODEMP.workspace.name)
|
||||||
|
workspace.leave()
|
||||||
|
end
|
||||||
print(" xx disconnecting client " .. CODEMP.client.id)
|
print(" xx disconnecting client " .. CODEMP.client.id)
|
||||||
CODEMP.client = nil -- should drop and thus close everything
|
CODEMP.client = nil -- should drop and thus close everything
|
||||||
collectgarbage("collect") -- make sure we drop
|
collectgarbage("collect") -- make sure we drop
|
||||||
|
|
|
@ -37,6 +37,10 @@ if CODEMP == nil then
|
||||||
{"ExitPre"},
|
{"ExitPre"},
|
||||||
{
|
{
|
||||||
callback = function (_ev)
|
callback = function (_ev)
|
||||||
|
if CODEMP.workspace ~= nil then
|
||||||
|
print(" xx leaving workspace " .. CODEMP.workspace.name)
|
||||||
|
require('codemp.workspace').leave()
|
||||||
|
end
|
||||||
if CODEMP.client ~= nil then
|
if CODEMP.client ~= nil then
|
||||||
print(" xx disconnecting codemp client")
|
print(" xx disconnecting codemp client")
|
||||||
CODEMP.client = nil -- drop reference so it gets garbage collected
|
CODEMP.client = nil -- drop reference so it gets garbage collected
|
||||||
|
|
|
@ -116,6 +116,7 @@ M.delete = function(state, path, extra)
|
||||||
if selected.type == "title" then
|
if selected.type == "title" then
|
||||||
vim.ui.input({ prompt = "disconnect from server?" }, function(choice)
|
vim.ui.input({ prompt = "disconnect from server?" }, function(choice)
|
||||||
if not choice or not vim.startswith(string.lower(choice), "y") then return end
|
if not choice or not vim.startswith(string.lower(choice), "y") then return end
|
||||||
|
if CODEMP.workspace ~= nil then ws_manager.leave() end
|
||||||
CODEMP.client = nil
|
CODEMP.client = nil
|
||||||
collectgarbage("collect") -- to make sure we drop the reference and disconnect
|
collectgarbage("collect") -- to make sure we drop the reference and disconnect
|
||||||
end)
|
end)
|
||||||
|
|
Loading…
Reference in a new issue