From a2e19be5fd97b5b206e86db7aa02b827748c931f Mon Sep 17 00:00:00 2001 From: Lin Tinusgrag Date: Tue, 24 Sep 2024 03:53:29 +0800 Subject: [PATCH] fix: use of possibly stale value The return value of `core.get_explorer()` could be changed by `core.init(..)`. --- lua/nvim-tree/lib.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lua/nvim-tree/lib.lua b/lua/nvim-tree/lib.lua index 83c0b61268e..dc56b966e98 100644 --- a/lua/nvim-tree/lib.lua +++ b/lua/nvim-tree/lib.lua @@ -263,8 +263,6 @@ end function M.open(opts) opts = opts or {} - local explorer = core.get_explorer() - M.set_target_win() if not core.get_explorer() or opts.path then if opts.path then @@ -278,6 +276,9 @@ function M.open(opts) core.init(cwd) end end + + local explorer = core.get_explorer() + if should_hijack_current_buf() then view.close_this_tab_only() view.open_in_win()