Skip to content

fix: revert relative path #524

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions lua/nvim-tree.lua
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ local keypress_funcs = {
close = function() M.close() end,
preview = function(node)
if node.entries ~= nil or node.name == '..' then return end
return lib.open_file('preview', node.relative_path)
return lib.open_file('preview', node.absolute_path)
end,
}

Expand All @@ -109,11 +109,11 @@ function M.on_keypress(mode)
end

if node.link_to and not node.entries then
lib.open_file(mode, utils.path_relative(node.absolute_path, vim.fn.getcwd(-1, 0)))
lib.open_file(mode, node.link_to)
elseif node.entries ~= nil then
lib.unroll_dir(node)
else
lib.open_file(mode, utils.path_relative(node.absolute_path, vim.fn.getcwd(-1, 0)))
lib.open_file(mode, node.absolute_path)
end
end

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

if with_open then
M.open()
view.focus()
if not is_file_readable(filepath) then return end
lib.set_index_and_redraw(filepath)
return
end

if not is_file_readable(filepath) then return end
lib.set_index_and_redraw(filepath)
end

Expand Down
5 changes: 0 additions & 5 deletions lua/nvim-tree/populate.lua
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,10 @@ end

local function file_new(cwd, name)
local absolute_path = utils.path_join({cwd, name})
local relative_path = utils.path_relative(absolute_path, luv.cwd())
local is_exec = luv.fs_access(absolute_path, 'X')
return {
name = name,
absolute_path = absolute_path,
relative_path = relative_path,
executable = is_exec,
extension = string.match(name, ".?[^.]+%.(.*)") or "",
match_name = path_to_matching_str(name),
Expand All @@ -64,8 +62,6 @@ local function link_new(cwd, name)
--- 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.
local absolute_path = utils.path_join({ cwd, name })
local link_to = luv.fs_realpath(absolute_path)
-- if links to a file outside cwd, relative_path equals absolute_path
local relative_path = link_to ~= nil and utils.path_relative(link_to, luv.cwd()) or nil
local stat = luv.fs_stat(absolute_path)
local open, entries
if (link_to ~= nil) and luv.fs_stat(link_to).type == 'directory' then
Expand All @@ -81,7 +77,6 @@ local function link_new(cwd, name)
return {
name = name,
absolute_path = absolute_path,
relative_path = relative_path,
link_to = link_to,
last_modified = last_modified,
open = open,
Expand Down