feat: add cwd arg to open_replacing_current_buffer (#1348)

This commit is contained in:
javiertury
2022-06-19 05:59:35 +02:00
committed by GitHub
parent 1fc0eee946
commit 6b7b1b34fa

View File

@@ -95,18 +95,22 @@ function M.open(cwd)
end
end
function M.open_replacing_current_buffer()
function M.open_replacing_current_buffer(cwd)
if view.is_visible() then
return
end
local buf = api.nvim_get_current_buf()
local bufname = api.nvim_buf_get_name(buf)
if bufname == "" or vim.loop.fs_stat(bufname) == nil then
if cwd == "" or cwd == nil then
if bufname ~= "" and vim.loop.fs_stat(bufname) ~= nil then
cwd = vim.fn.fnamemodify(bufname, ":p:h")
else
return
end
end
local cwd = vim.fn.fnamemodify(bufname, ":p:h")
if not core.get_explorer() or cwd ~= core.get_cwd() then
core.init(cwd)
end