Skip to content

Commit 102c4c2

Browse files
committed
fix(path relative): open file relative by matching tab path
1 parent b933ae8 commit 102c4c2

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

lua/nvim-tree.lua

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,11 @@ function M.on_keypress(mode)
102102
end
103103

104104
if node.link_to and not node.entries then
105-
lib.open_file(mode, node.relative_path)
105+
lib.open_file(mode, utils.path_relative(node.absolute_path, vim.fn.getcwd(-1, 0)))
106106
elseif node.entries ~= nil then
107107
lib.unroll_dir(node)
108108
else
109-
lib.open_file(mode, node.relative_path)
109+
lib.open_file(mode, utils.path_relative(node.absolute_path, vim.fn.getcwd(-1, 0)))
110110
end
111111
end
112112

@@ -148,16 +148,13 @@ end
148148
function M.find_file(with_open)
149149
local bufname = vim.fn.bufname()
150150
local filepath = vim.fn.fnamemodify(bufname, ':p')
151+
if not is_file_readable(filepath) or vim.fn.isdirectory(filepath) == 1 then return end
151152

152153
if with_open then
153154
M.open()
154155
view.focus()
155-
if not is_file_readable(filepath) then return end
156-
lib.set_index_and_redraw(filepath)
157-
return
158156
end
159157

160-
if not is_file_readable(filepath) then return end
161158
lib.set_index_and_redraw(filepath)
162159
end
163160

0 commit comments

Comments
 (0)