Skip to content

Commit fdf63e5

Browse files
authored
fix: use fs_realpath to normalize path (#978)
1 parent d34ea42 commit fdf63e5

File tree

2 files changed

+1
-21
lines changed

2 files changed

+1
-21
lines changed

lua/nvim-tree/explorer/init.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ local Explorer = {}
1313
Explorer.__index = Explorer
1414

1515
function Explorer.new(cwd)
16-
cwd = utils.path_normalize(cwd or uv.cwd())
16+
cwd = uv.fs_realpath(cwd or uv.cwd())
1717
return setmetatable({
1818
cwd = cwd,
1919
nodes = {}

lua/nvim-tree/utils.lua

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -208,24 +208,4 @@ function M.file_exists(path)
208208
return error == nil
209209
end
210210

211-
--- @param num number elements to take
212-
--- @param list table elements
213-
--- @return table
214-
function M.take(num, list)
215-
local t = {}
216-
for i, c in ipairs(list) do
217-
if i > num then break end
218-
table.insert(t, c)
219-
end
220-
return t
221-
end
222-
223-
--- @param path string
224-
--- @return string
225-
function M.path_normalize(path)
226-
local components = vim.split(vim.fn.expand(path), path_separator)
227-
local num_dots = #vim.tbl_filter(function(v) return v == ".." end, components)
228-
return M.path_join(M.take(#components - num_dots * 2, components))
229-
end
230-
231211
return M

0 commit comments

Comments
 (0)