From 418b1e85725d582addc109c9f401c99ba7e901a8 Mon Sep 17 00:00:00 2001 From: kiyan Date: Mon, 19 Jul 2021 23:51:51 +0200 Subject: [PATCH 1/3] Revert "fix(path relative): open file relative by matching tab path" This reverts commit 102c4c2332eb49711b0b1bb63dabc67355fc2a32. --- lua/nvim-tree.lua | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lua/nvim-tree.lua b/lua/nvim-tree.lua index 49350e759ac..4fc9f141f64 100644 --- a/lua/nvim-tree.lua +++ b/lua/nvim-tree.lua @@ -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.relative_path) 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.relative_path) end end @@ -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 From f420daa7e0afa80c8829e97b608b59a91d0a304f Mon Sep 17 00:00:00 2001 From: kiyan Date: Mon, 19 Jul 2021 23:52:05 +0200 Subject: [PATCH 2/3] Revert "Fix error caused by broken symlinks (#494)" This reverts commit 933d69a37fa5e7a89dc7470376fbed9e692f4253. --- lua/nvim-tree/populate.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/nvim-tree/populate.lua b/lua/nvim-tree/populate.lua index 8126c8ba127..2bcb46bce85 100644 --- a/lua/nvim-tree/populate.lua +++ b/lua/nvim-tree/populate.lua @@ -65,7 +65,7 @@ local function link_new(cwd, name) 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 relative_path = utils.path_relative(link_to, luv.cwd()) local stat = luv.fs_stat(absolute_path) local open, entries if (link_to ~= nil) and luv.fs_stat(link_to).type == 'directory' then From 099f905e5ca93e12f455deb98a0d820c69ab5dd7 Mon Sep 17 00:00:00 2001 From: kiyan Date: Mon, 19 Jul 2021 23:52:31 +0200 Subject: [PATCH 3/3] Revert "open file with relative path when possible (#487)" This reverts commit db9e70fde50ae3aa3b2942d493b5a868b3515211. --- lua/nvim-tree.lua | 6 +++--- lua/nvim-tree/populate.lua | 5 ----- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/lua/nvim-tree.lua b/lua/nvim-tree.lua index 4fc9f141f64..26f15c2f2cd 100644 --- a/lua/nvim-tree.lua +++ b/lua/nvim-tree.lua @@ -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, } @@ -109,11 +109,11 @@ function M.on_keypress(mode) end if node.link_to and not node.entries then - lib.open_file(mode, node.relative_path) + lib.open_file(mode, node.link_to) elseif node.entries ~= nil then lib.unroll_dir(node) else - lib.open_file(mode, node.relative_path) + lib.open_file(mode, node.absolute_path) end end diff --git a/lua/nvim-tree/populate.lua b/lua/nvim-tree/populate.lua index 2bcb46bce85..00ced840550 100644 --- a/lua/nvim-tree/populate.lua +++ b/lua/nvim-tree/populate.lua @@ -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), @@ -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 = utils.path_relative(link_to, luv.cwd()) local stat = luv.fs_stat(absolute_path) local open, entries if (link_to ~= nil) and luv.fs_stat(link_to).type == 'directory' then @@ -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,