fix(explorer): windows

This commit is contained in:
Folke Lemaitre 2025-02-04 16:56:05 +01:00
parent 225a79339c
commit b560054669
No known key found for this signature in database
GPG key ID: 36B7C1C85AAC487F

View file

@ -52,8 +52,9 @@ function Tree:find(path)
if self.nodes[path] then
return self.nodes[path]
end
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
for p, part in ipairs(parts) do
node = self:child(node, part, (is_dir or p < #parts) and "directory" or "file")
@ -66,7 +67,7 @@ end
---@param type string
function Tree:child(node, name, type)
if not node.children[name] then
local path = (node.path .. "/" .. name)
local path = ((node.path == "" and "" or (node.path .. "/")) .. name)
node.children[name] = {
name = name,
path = path,