fix: opening tree

opening the tree checks bufname is directory properly and do not render
before initializing when tree is nil.
This commit is contained in:
kiyan
2022-02-20 21:48:46 +01:00
parent 209bc3d2ef
commit 83f398ee8f

View File

@@ -126,7 +126,7 @@ local function should_hijack_current_buf()
and not bufmodified and not bufmodified
and ft == "" and ft == ""
local should_hijack_dir = bufname ~= "" local should_hijack_dir = bufname ~= ""
and vim.fn.isdirectory(bufname) and vim.fn.isdirectory(bufname) == 1
and M.hijack_directories.enable and M.hijack_directories.enable
return should_hijack_dir or should_hijack_unnamed return should_hijack_dir or should_hijack_unnamed
@@ -135,7 +135,7 @@ end
function M.open(cwd) function M.open(cwd)
M.set_target_win() M.set_target_win()
if not TreeExplorer or cwd then if not TreeExplorer or cwd then
M.init(false, cwd or vim.loop.cwd()) return M.init(true, cwd or vim.loop.cwd())
end end
if should_hijack_current_buf() then if should_hijack_current_buf() then
view.open_in_current_win() view.open_in_current_win()