fix(path relative): open file relative by matching tab path

This commit is contained in:
kiyan
2021-07-10 10:52:14 +02:00
parent b933ae856f
commit 102c4c2332

View File

@@ -102,11 +102,11 @@ function M.on_keypress(mode)
end end
if node.link_to and not node.entries then if node.link_to and not node.entries then
lib.open_file(mode, node.relative_path) lib.open_file(mode, utils.path_relative(node.absolute_path, vim.fn.getcwd(-1, 0)))
elseif node.entries ~= nil then elseif node.entries ~= nil then
lib.unroll_dir(node) lib.unroll_dir(node)
else else
lib.open_file(mode, node.relative_path) lib.open_file(mode, utils.path_relative(node.absolute_path, vim.fn.getcwd(-1, 0)))
end end
end end
@@ -148,16 +148,13 @@ end
function M.find_file(with_open) function M.find_file(with_open)
local bufname = vim.fn.bufname() local bufname = vim.fn.bufname()
local filepath = vim.fn.fnamemodify(bufname, ':p') 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 if with_open then
M.open() M.open()
view.focus() view.focus()
if not is_file_readable(filepath) then return end
lib.set_index_and_redraw(filepath)
return
end end
if not is_file_readable(filepath) then return end
lib.set_index_and_redraw(filepath) lib.set_index_and_redraw(filepath)
end end