fix(explorer.tree): fix linux

This commit is contained in:
Folke Lemaitre 2025-02-04 18:18:26 +01:00
parent c255d9c6a0
commit 6f5399b47c
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040

View file

@ -54,7 +54,7 @@ function Tree:find(path)
end end
local node = self.root local node = self.root
local parts = vim.split(path, "/", { plain = true }) local parts = vim.split(path:gsub("^/", ""), "/", { plain = true })
local is_dir = vim.fn.isdirectory(path) == 1 local is_dir = vim.fn.isdirectory(path) == 1
for p, part in ipairs(parts) do for p, part in ipairs(parts) do
node = self:child(node, part, (is_dir or p < #parts) and "directory" or "file") node = self:child(node, part, (is_dir or p < #parts) and "directory" or "file")
@ -67,7 +67,7 @@ end
---@param type string ---@param type string
function Tree:child(node, name, type) function Tree:child(node, name, type)
if not node.children[name] then if not node.children[name] then
local path = ((node.path == "" and "" or (node.path .. "/")) .. name) local path = node.path .. "/" .. name
node.children[name] = { node.children[name] = {
name = name, name = name,
path = path, path = path,