Skip to content

Commit 4cc6b1b

Browse files
committed
prevent looping
1 parent a1618f2 commit 4cc6b1b

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

lua/neo-tree/utils/init.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -960,6 +960,10 @@ end
960960
---@return string? err Error string
961961
M.fs_parent = function(path, loose)
962962
path = M.path_join(vim.fn.getcwd(), path)
963+
local prefix = M.abspath_prefix(path)
964+
if prefix and #prefix >= #path then
965+
return nil
966+
end
963967

964968
local stat = uv.fs_lstat(path)
965969

tests/neo-tree/utils/fs_spec.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ local uv = vim.uv or vim.loop
55
describe("fs_parent", function()
66
it("works", function()
77
assert.are.same(nil, utils.fs_parent("/"))
8-
assert.are.same(uv.fs_realpath("/"), utils.fs_parent("/foo"))
9-
assert.are.same(uv.fs_realpath("/"), utils.fs_parent("/foo/bar", true))
8+
assert.are.same(utils.path_separator, utils.fs_parent("/foo"))
9+
assert.are.same(utils.path_separator, utils.fs_parent("/foo/bar", true))
1010
assert.are.same(nil, utils.fs_parent("/foo/bar", false))
1111
end)
1212
end)

0 commit comments

Comments
 (0)