diff --git a/lua/nvim-tree.lua b/lua/nvim-tree.lua index 2af6df6b..489c3f0d 100644 --- a/lua/nvim-tree.lua +++ b/lua/nvim-tree.lua @@ -794,20 +794,19 @@ function M.setup(conf) end setup_autocommands(opts) - require("nvim-tree.watcher").purge_watchers() if not M.setup_called then + -- first call to setup setup_vim_commands() - end - - if M.setup_called then + else + -- subsequent calls to setup + require("nvim-tree.watcher").purge_watchers() view.close_all_tabs() view.abandon_all_windows() - end - - if M.setup_called and core.get_explorer() ~= nil then - git.purge_state() - TreeExplorer = nil + if core.get_explorer() ~= nil then + git.purge_state() + TreeExplorer = nil + end end M.setup_called = true diff --git a/lua/nvim-tree/git/init.lua b/lua/nvim-tree/git/init.lua index e1616950..083d45a6 100644 --- a/lua/nvim-tree/git/init.lua +++ b/lua/nvim-tree/git/init.lua @@ -173,6 +173,7 @@ function M.load_project_status(cwd) end function M.purge_state() + log.line("git", "purge_state") M.projects = {} M.cwd_to_project_root = {} end