From fdf63e572dac2fed219f77a9b05405bcd131220f Mon Sep 17 00:00:00 2001 From: Xavier Young <45989017+younger-1@users.noreply.github.com> Date: Tue, 15 Feb 2022 15:33:11 +0800 Subject: [PATCH] fix: use fs_realpath to normalize path (#978) --- lua/nvim-tree/explorer/init.lua | 2 +- lua/nvim-tree/utils.lua | 20 -------------------- 2 files changed, 1 insertion(+), 21 deletions(-) diff --git a/lua/nvim-tree/explorer/init.lua b/lua/nvim-tree/explorer/init.lua index efad47fe..b9d6222c 100644 --- a/lua/nvim-tree/explorer/init.lua +++ b/lua/nvim-tree/explorer/init.lua @@ -13,7 +13,7 @@ local Explorer = {} Explorer.__index = Explorer function Explorer.new(cwd) - cwd = utils.path_normalize(cwd or uv.cwd()) + cwd = uv.fs_realpath(cwd or uv.cwd()) return setmetatable({ cwd = cwd, nodes = {} diff --git a/lua/nvim-tree/utils.lua b/lua/nvim-tree/utils.lua index a417ff3d..27a827b5 100644 --- a/lua/nvim-tree/utils.lua +++ b/lua/nvim-tree/utils.lua @@ -208,24 +208,4 @@ function M.file_exists(path) return error == nil end ---- @param num number elements to take ---- @param list table elements ---- @return table -function M.take(num, list) - local t = {} - for i, c in ipairs(list) do - if i > num then break end - table.insert(t, c) - end - return t -end - ---- @param path string ---- @return string -function M.path_normalize(path) - local components = vim.split(vim.fn.expand(path), path_separator) - local num_dots = #vim.tbl_filter(function(v) return v == ".." end, components) - return M.path_join(M.take(#components - num_dots * 2, components)) -end - return M