mirror of
https://github.com/hexedtech/codemp-nvim.git
synced 2024-11-21 23:14:54 +01:00
fix: tree redraw, always expand nodes
This commit is contained in:
parent
eda004423e
commit
16f9bd77fd
3 changed files with 9 additions and 10 deletions
|
@ -124,13 +124,18 @@ M.update_state = function(state)
|
|||
}
|
||||
}
|
||||
|
||||
state.force_open_folders = true
|
||||
state.default_expanded_nodes = {}
|
||||
|
||||
if CODEMP.workspace ~= nil then
|
||||
local ws_section = new_root("#" .. CODEMP.workspace.name)
|
||||
table.insert(state.default_expanded_nodes, ws_section.id)
|
||||
for i, path in ipairs(CODEMP.workspace:filetree()) do
|
||||
table.insert(ws_section.children, new_item(CODEMP.workspace.name, path))
|
||||
end
|
||||
|
||||
local usr_section = new_root("users")
|
||||
table.insert(state.default_expanded_nodes, usr_section.id)
|
||||
for user, buffer in pairs(buf_manager.users) do
|
||||
table.insert(usr_section.children, new_user(CODEMP.workspace.name, user))
|
||||
end
|
||||
|
@ -143,6 +148,7 @@ M.update_state = function(state)
|
|||
|
||||
if CODEMP.client ~= nil then
|
||||
local ws_section = new_root("workspaces")
|
||||
table.insert(state.default_expanded_nodes, ws_section.id)
|
||||
for _, ws in ipairs(CODEMP.available) do
|
||||
table.insert(ws_section.children, new_workspace(ws.name, ws.owned))
|
||||
end
|
||||
|
@ -150,6 +156,7 @@ M.update_state = function(state)
|
|||
table.insert(root, ws_section)
|
||||
|
||||
local status_section = new_root("client")
|
||||
table.insert(state.default_expanded_nodes, status_section.id)
|
||||
table.insert(status_section.children, new_entry("id", CODEMP.client.id))
|
||||
table.insert(status_section.children, new_entry("name", CODEMP.client.username))
|
||||
|
||||
|
@ -163,13 +170,6 @@ M.update_state = function(state)
|
|||
end
|
||||
|
||||
renderer.show_nodes(root, state)
|
||||
|
||||
local new_state = "disconnected"
|
||||
if CODEMP.client ~= nil then new_state = "connected" end
|
||||
if CODEMP.workspace ~= nil then new_state = "joined" end
|
||||
|
||||
if last_state ~= new_state then expand(state.tree) end
|
||||
last_state = new_state
|
||||
end
|
||||
|
||||
return M
|
||||
|
|
|
@ -38,7 +38,6 @@ M.open = function(state, path, extra)
|
|||
if CODEMP.workspace == nil then
|
||||
ws_manager.join(selected.name)
|
||||
end
|
||||
manager.refresh("codemp")
|
||||
return
|
||||
end
|
||||
if selected.type == "buffer" then
|
||||
|
@ -108,7 +107,6 @@ M.delete = function(state, path, extra)
|
|||
if input == nil 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 CODEMP.workspace == nil then error("join a workspace first") end
|
||||
|
@ -147,6 +145,7 @@ M.add = function(state, path, extra)
|
|||
vim.ui.input({ prompt = "new workspace name" }, function(input)
|
||||
if input == nil or input == "" then return end
|
||||
CODEMP.client:create_workspace(input):and_then(function ()
|
||||
manager.refresh("codemp")
|
||||
require('codemp.workspace').list()
|
||||
end)
|
||||
end)
|
||||
|
@ -159,7 +158,6 @@ M.add = function(state, path, extra)
|
|||
end)
|
||||
end)
|
||||
end
|
||||
manager.refresh("codemp")
|
||||
end
|
||||
|
||||
cc._add_common_commands(M)
|
||||
|
|
|
@ -146,6 +146,7 @@ local function leave()
|
|||
CODEMP.client:leave_workspace(CODEMP.workspace.name)
|
||||
print(" -- left workspace")
|
||||
CODEMP.workspace = nil
|
||||
require('codemp.window').update()
|
||||
end
|
||||
|
||||
return {
|
||||
|
|
Loading…
Reference in a new issue