Skip to content

Commit 099f905

Browse files
committed
Revert "open file with relative path when possible (#487)"
This reverts commit db9e70f.
1 parent f420daa commit 099f905

File tree

2 files changed

+3
-8
lines changed

2 files changed

+3
-8
lines changed

lua/nvim-tree.lua

Lines changed: 3 additions & 3 deletions
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, node.relative_path)
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, node.relative_path)
116+
lib.open_file(mode, node.absolute_path)
117117
end
118118
end
119119

lua/nvim-tree/populate.lua

Lines changed: 0 additions & 5 deletions
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 = utils.path_relative(link_to, luv.cwd())
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)