fix(exporer.tree): and now hopefully on windows

This commit is contained in:
Folke Lemaitre 2025-02-04 18:22:45 +01:00
parent 6f5399b47c
commit ef9b12d680
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:gsub("^/", ""), "/", { plain = true }) local parts = vim.split(path, "/", { 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")
@ -68,6 +68,7 @@ end
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 .. "/" .. name local path = node.path .. "/" .. name
path = node == self.root and name or path
node.children[name] = { node.children[name] = {
name = name, name = name,
path = path, path = path,