mirror of
https://github.com/folke/snacks.nvim
synced 2025-08-05 03:08:13 +00:00
fix(explorer): windows
This commit is contained in:
parent
225a79339c
commit
b560054669
1 changed files with 3 additions and 2 deletions
|
@ -52,8 +52,9 @@ function Tree:find(path)
|
||||||
if self.nodes[path] then
|
if self.nodes[path] then
|
||||||
return self.nodes[path]
|
return self.nodes[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")
|
||||||
|
@ -66,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 .. "/" .. name)
|
local path = ((node.path == "" and "" or (node.path .. "/")) .. name)
|
||||||
node.children[name] = {
|
node.children[name] = {
|
||||||
name = name,
|
name = name,
|
||||||
path = path,
|
path = path,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue