Skip to content

Commit 07e92cd

Browse files
authored
fix: revert relative path (#524)
1 parent 42b2324 commit 07e92cd

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

lua/nvim-tree.lua

+7-4
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ local keypress_funcs = {
8787
close = function() M.close() end,
8888
preview = function(node)
8989
if node.entries ~= nil or node.name == '..' then return end
90-
return lib.open_file('preview', node.relative_path)
90+
return lib.open_file('preview', node.absolute_path)
9191
end,
9292
}
9393

@@ -109,11 +109,11 @@ function M.on_keypress(mode)
109109
end
110110

111111
if node.link_to and not node.entries then
112-
lib.open_file(mode, utils.path_relative(node.absolute_path, vim.fn.getcwd(-1, 0)))
112+
lib.open_file(mode, node.link_to)
113113
elseif node.entries ~= nil then
114114
lib.unroll_dir(node)
115115
else
116-
lib.open_file(mode, utils.path_relative(node.absolute_path, vim.fn.getcwd(-1, 0)))
116+
lib.open_file(mode, node.absolute_path)
117117
end
118118
end
119119

@@ -155,13 +155,16 @@ end
155155
function M.find_file(with_open)
156156
local bufname = vim.fn.bufname()
157157
local filepath = vim.fn.fnamemodify(bufname, ':p')
158-
if not is_file_readable(filepath) or vim.fn.isdirectory(filepath) == 1 then return end
159158

160159
if with_open then
161160
M.open()
162161
view.focus()
162+
if not is_file_readable(filepath) then return end
163+
lib.set_index_and_redraw(filepath)
164+
return
163165
end
164166

167+
if not is_file_readable(filepath) then return end
165168
lib.set_index_and_redraw(filepath)
166169
end
167170

lua/nvim-tree/populate.lua

-5
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,10 @@ end
4141

4242
local function file_new(cwd, name)
4343
local absolute_path = utils.path_join({cwd, name})
44-
local relative_path = utils.path_relative(absolute_path, luv.cwd())
4544
local is_exec = luv.fs_access(absolute_path, 'X')
4645
return {
4746
name = name,
4847
absolute_path = absolute_path,
49-
relative_path = relative_path,
5048
executable = is_exec,
5149
extension = string.match(name, ".?[^.]+%.(.*)") or "",
5250
match_name = path_to_matching_str(name),
@@ -64,8 +62,6 @@ local function link_new(cwd, name)
6462
--- I dont know if this is needed, because in my understanding, there isnt hard links in windows, but just to be sure i changed it.
6563
local absolute_path = utils.path_join({ cwd, name })
6664
local link_to = luv.fs_realpath(absolute_path)
67-
-- if links to a file outside cwd, relative_path equals absolute_path
68-
local relative_path = link_to ~= nil and utils.path_relative(link_to, luv.cwd()) or nil
6965
local stat = luv.fs_stat(absolute_path)
7066
local open, entries
7167
if (link_to ~= nil) and luv.fs_stat(link_to).type == 'directory' then
@@ -81,7 +77,6 @@ local function link_new(cwd, name)
8177
return {
8278
name = name,
8379
absolute_path = absolute_path,
84-
relative_path = relative_path,
8580
link_to = link_to,
8681
last_modified = last_modified,
8782
open = open,

0 commit comments

Comments
 (0)