refacto: tree explorer root should be absolute_path not cwd

This commit is contained in:
kiyan
2022-05-29 11:40:06 +02:00
parent 3806653d75
commit 5e900c2f29
9 changed files with 12 additions and 12 deletions

View File

@@ -59,7 +59,7 @@ local function get_dir_handle(cwd)
end
function M.explore(node, status)
local cwd = node.cwd or node.link_to or node.absolute_path
local cwd = node.link_to or node.absolute_path
local handle = get_dir_handle(cwd)
if not handle then
return
@@ -67,7 +67,7 @@ function M.explore(node, status)
populate_children(handle, cwd, node, status)
local is_root = node.cwd ~= nil
local is_root = not node.parent
local child_folder_only = common.has_one_child_folder(node) and node.nodes[1]
if M.config.group_empty and not is_root and child_folder_only then
node.group_next = child_folder_only

View File

@@ -13,7 +13,7 @@ Explorer.__index = Explorer
function Explorer.new(cwd)
cwd = uv.fs_realpath(cwd or uv.cwd())
local explorer = setmetatable({
cwd = cwd,
absolute_path = cwd,
nodes = {},
}, Explorer)
explorer:_load(explorer)
@@ -21,7 +21,7 @@ function Explorer.new(cwd)
end
function Explorer:_load(node)
local cwd = node.cwd or node.link_to or node.absolute_path
local cwd = node.link_to or node.absolute_path
local git_statuses = git.load_project_status(cwd)
M.explore(node, git_statuses)
end

View File

@@ -20,7 +20,7 @@ local function update_status(nodes_by_path, node_ignored, status)
end
function M.reload(node, status)
local cwd = node.cwd or node.link_to or node.absolute_path
local cwd = node.link_to or node.absolute_path
local handle = uv.fs_scandir(cwd)
if type(handle) == "string" then
api.nvim_err_writeln(handle)
@@ -68,7 +68,7 @@ function M.reload(node, status)
end, node.nodes)
)
local is_root = node.cwd ~= nil
local is_root = not node.parent
local child_folder_only = common.has_one_child_folder(node) and node.nodes[1]
if M.config.group_empty and not is_root and child_folder_only then
node.group_next = child_folder_only