Skip to content

Commit 76583b7

Browse files
authored
Fix error caused by broken symlinks (nvim-tree#494)
When a symbolic link points to an invalid path, the value of `link_to` equals `nil`. This value makes `utils.path_relative` throw an error, since it expects a string as the first argument
1 parent 6c8790f commit 76583b7

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lua/nvim-tree/populate.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ local function link_new(cwd, name)
6565
local absolute_path = utils.path_join({ cwd, name })
6666
local link_to = luv.fs_realpath(absolute_path)
6767
-- if links to a file outside cwd, relative_path equals absolute_path
68-
local relative_path = utils.path_relative(link_to, luv.cwd())
68+
local relative_path = link_to ~= nil and utils.path_relative(link_to, luv.cwd()) or nil
6969
local stat = luv.fs_stat(absolute_path)
7070
local open, entries
7171
if (link_to ~= nil) and luv.fs_stat(link_to).type == 'directory' then

0 commit comments

Comments
 (0)